Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Coalesce questions with the same name #36

Open
dpashouwer opened this issue Jul 30, 2019 · 2 comments
Open

Coalesce questions with the same name #36

dpashouwer opened this issue Jul 30, 2019 · 2 comments

Comments

@dpashouwer
Copy link
Collaborator

dpashouwer commented Jul 30, 2019

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
Copy link
Collaborator

sfirke commented Jul 31, 2019

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
Copy link
Collaborator Author

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants