mattroumaya / surveymonkey

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

Make variables where all choices are numeric into class numeric #15

Open sfirke opened 5 years ago

sfirke commented 5 years ago

Currently character. Low priority.

sfirke commented 5 years ago

Use this? https://stackoverflow.com/a/13638403

sfirke commented 5 years ago

It was easy to implement here: https://github.com/tntp/surveymonkey/commit/c27f1fb45e5687400028fb51b956481c702fdda8#diff-aefe1936aed0769d26de737a9fec03f3R102-R103

But I'm not going to merge without others chiming in. Because if it truly should be treated as a factor - in particular, if the asked-but-not-selected missing levels are meaningful - they'll be lost. That's irretrievable. On the other hand, to make the factor into a numeric is simply as.numeric(as.character(x)). So even if the numeric result is usually preferable, keeping it as a factor feels safer.

sfirke commented 4 years ago

If this is implemented, it should only be as an option with the default being factors. And I'm smiling at the idea of a user typing numbersAsFactors = FALSE 😉

sfirke commented 4 years ago

Make this sm_-something, like sm_unfactorize_numbers. This function should have tests, if implemented.

sfirke commented 3 years ago

I considered this here: https://github.com/sfirke/janitor/issues/447 and decided readr::type_convert was perfectly good already. Could use that if this feature is implemented.