mattroumaya / surveymonkey

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

re-write paste to fix NA column issue #71

Closed mattroumaya closed 3 years ago

mattroumaya commented 3 years ago

I've tested this out on four separate surveys that have multiple_choice and/or multi questions with "other" fields, and seems to fix the issue by being more explicit with the paste call. I'm hoping this will also be easier to mend if there are additional question types added to SurveyMonkey in the future that might require additional edits.

sfirke commented 3 years ago

It looks like a good reformulation of that one block of code with all the subsetting brackets. Does it include the functionality you're removing with this line x$combined_q_heading <- trimws(gsub('^\\ - NA|\\ - NA$', '', x$combined_q_heading)) ?

mattroumaya commented 3 years ago

Yes, I believe it makes that line unnecessary, because there is no longer the issue of the " - NA" appended to the end of the column names.

sfirke commented 3 years ago

Ah I get it now, before it was question_type == "multiple_choice" and now it's question_type == "multiple_choice" & is.na(other_text) with that tighter restriction. Looks good to me then!

mattroumaya commented 3 years ago

Thanks, @sfirke!!