Skip to content
Prev 363376 / 398502 Next

[R Survey Analysis] Problem counting number of responses

Hi Lauren,
As Sarah noted, if your blank responses are coming as NAs, it may be
best to leave them alone until you have done the calculations:

survey$responses<-!is.na(survey[,c("q1","q2","q3")])
survey$sum_survey<-rowSums(survey[,c("q1","q2","q3")],na.rm=TRUE)
# the next line returns a logical vector that you can use to subset
# like this survey[q_complete,]
q_complete<-complete.cases(survey[,c("q1","q2","q3")])

then set your NAs to zeros if you need to.

Jim
On Wed, Aug 17, 2016 at 4:51 AM, Lauren Bolger <lebolger at gmail.com> wrote: