I'm using the group_by function in dplyr, however, in the variable that I'm grouping by, there are NAs, which group_by is making into a seperate group. For example, I'm using the following code that has the output:
> education <- group_by(data, DMDEDUC2)
> ed.prop <- summarise(education,
+ total = n(),
+ num.obese = sum(as.numeric(is.obese)),
+ pbar = num.obese/total,
+ margin = qnorm(.975)*sqrt(pbar*(1-pbar)/total),
+ lower = pbar - margin,
+ upper = pbar + margin
+ )
> ed.prop <- select(ed.prop, education = DMDEDUC2, total, num.obese, pbar, lower, upper)
> ed.prop
Source: local data frame [6 x 6]
education total num.obese pbar lower upper
1 1 501 170 0.3393214 0.2978613 0.3807814
2 2 734 297 0.4046322 0.3691244 0.4401399
3 3 1098 448 0.4080146 0.3789449 0.4370843
4 4 1576 605 0.3838832 0.3598728 0.4078937
5 5 1324 353 0.2666163 0.2427979 0.2904347
6 NA 4 0 0.0000000 0.0000000 0.0000000
How can I make it so that the last row isn't generated? I've already tried na.rm = TRUE as an argument in group_by() and that didn't work.