mattroumaya / surveymonkey

Access your SurveyMonkey data directly from R!
https://mattroumaya.github.io/surveymonkey/
Other
42 stars 10 forks source link

Coalesce questions with the same name #36

Open dpashouwer opened 5 years ago

dpashouwer commented 5 years ago

Ran into a logic limitation in SM where I had to repeat a question for different sub-groups of respondents (ie. same question asked in two different places). surveymonkey::parse_survey added "_2" and "_3" to the second and third instances of the question. This might indeed be exactly what we want as it's very explicit.

But then in my code I had to coalesce these questions into one column. Maybe we could add a "coalesce" argument to parse_survey, that would combine these duplicated questions.

There could be problems with this though. For example, if a respondent was able to answer the same question twice it would only keep the first response.

sfirke commented 5 years ago

I considered this in #17. If it is a rigid choice between adding _2 or auto-coalescing, the former behavior is safer and matches the .csv export so I went with that. BUT I am intrigued by your proposed middle ground of a coalesce argument. I wonder how common this is; I would think <1% of surveys but on the other hand, this is the 2nd time it's come up.

I agree discussion is needed, we can leave as is while we (and I hope others eventually) discuss. Another option would be to provide a function that auto-coalesces the resulting data.frame, rather than adding an argument to parse_survey.

dpashouwer commented 5 years ago

FWIW I'll add the gather/spread solution I used in my code.

svy_raw %>% gather(question, response, a_student_who_...ic_organizers:lessons_target...ce_in_texts_2) %>% filter(!is.na(response)) %>% mutate(question = str_remove(question, "_2"), question = str_remove(question, "_3")) %>% spread(question, response)