Skip to content
Prev 363373 / 398502 Next

[R Survey Analysis] Problem counting number of responses

Hi Lauren,

I'm not entirely sure what your sample code is suppoesd to do, since
it isn't complete R code, and it would be much easier to answer your
question if you provided sample data and didn't post in HTML.

dput(head(survey))

would be enough sample data, most likely.

But if I'm understanding correctly,
nanswered <- rowSums(survey != 0)
will give you for each respondent the number of questions answered.

or if they're actually NA instead of 0
nanswered <- rowSums(!is.na(survey))

then you can look at the distribution of those values, and use that
vector with subset() to get the population that answered all of your
questions.

The advantage of this approach is that you don't have to list each
question individually, in case you have lots.

Sarah
On Tue, Aug 16, 2016 at 2:51 PM, Lauren Bolger <lebolger at gmail.com> wrote: