I am trying to give participant in my study an average value across a subscale of 20 questions. I first converted the string responses (ex. "Never (zero occasions)", "Rarely (one or two occasions", etc) to 1 through 5 numerical outputs using the following code:
dataset.clean1$Q11_22 <- revalue(dataset.clean1$Q11_22 , c("Never (zero occasions)" = "1" , "Rarely (one or two occasions)" = "2", "Multiple times (three or more occasions)" = "3", "Regularly (at least once every 1-3 months)" = "4", "Weekly (at least once a week)" = "5"))
i did this 20 times for each question (i know it's probably the least elegant method but it is all i know so far).
Now i am trying to get each participants average across Q11_22 to Q32_43 and get R to skip any blank/empty rows. i tried the following (not all twenty columns included so i could quickly test it out):
ave.exposure <- dataset.clean1$ave.exposure <- mean(dataset.clean1$Q11_22, dataset.clean1$Q12_23, dataset.clean1$Q13_24, na.rm=TRUE)
i got the following error:
Warning message: In mean.default(dataset.clean1$Q11_22, dataset.clean1$Q12_23, dataset.clean1$Q13_24, :argument is not numeric or logical: returning NA
Now i am confused about two things:
- do i need to not put the numeric values i am trying to replace my string with in
" "in step 1 (ex.
dataset.clean1$Q11_22 <- revalue(dataset.clean1$Q11_22 , c("Never (zero occasions)" = 1
instead of:
dataset.clean1$Q11_22 <- revalue(dataset.clean1$Q11_22 , c("Never (zero occasions)" = "1"`) ?
- how (in an easy to understand way, no matter how tedious) do i find the average for each participant across all these columns?