Conditional mean statement
问题 I have a dataset named bwght which contains the variable cigs (cigarattes smoked per day) When I calculate the mean of cigs in the dataset bwght using: mean(bwght$cigs) , I get a number 2.08. Only 212 of the 1388 women in the sample smoke (and 1176 does not smoke): summary(bwght$cigs>0) gives the result: Mode FALSE TRUE NA's logical 1176 212 0 I'm asked to find the average of cigs among the women who smoke (the 212). I'm having a hard time finding the right syntax for excluding the non