[R] [R Survey Analysis] Problem counting number of responses
drjimlemon at gmail.com
Wed Aug 17 02:03:58 CEST 2016
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:
# the next line returns a logical vector that you can use to subset
# like this survey[q_complete,]
then set your NAs to zeros if you need to.
On Wed, Aug 17, 2016 at 4:51 AM, Lauren Bolger <lebolger at gmail.com> wrote:
> y dataset includes a survey completed by research participants to evaluate
> quality of life. A few things regarding the survey:
> *not all questions must be answered for the total score *
> - questions left blank are coded as "0"
> - the number of questions answered must be determined in order to
> compute the total score
> *Sample Code*
>> q1 <- ifelse(is.na(survey, 0, survey$q1)
>> q2 <- ifelse(is.na(survey, 0, survey$q2)
>> q3 <- ifelse(is.na(survey, 0, survey$q3)
>> survey$sum.survey <- q1 + q2 + q3
>> survey$responses <- # HELP ?????
> *> # HELP PART 1 ------------------------------*
> *> # need help determining number of questions the respondents answered*
>> *# HELP PART 2 -------------------------------*
> *> # I want to look at the subset of the population that completed all the
> Thanks for your help!! It means a lot :)
> [[alternative HTML version deleted]]
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help