Open sfirke opened 5 years ago
Use this? https://stackoverflow.com/a/13638403
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.
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
😉
Make this sm_
-something, like sm_unfactorize_numbers
. This function should have tests, if implemented.
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.
Currently character. Low priority.