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

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

Open
sfirke opened this issue Apr 5, 2019 · 5 comments
Open

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

sfirke opened this issue Apr 5, 2019 · 5 comments
Labels
discussion needed enhancement New feature or request

Comments

@sfirke
Copy link
Collaborator

sfirke commented Apr 5, 2019

Currently character. Low priority.

@sfirke sfirke added the enhancement New feature or request label Apr 5, 2019
@sfirke
Copy link
Collaborator Author

sfirke commented May 14, 2019

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

sfirke added a commit that referenced this issue Jul 16, 2019
@sfirke
Copy link
Collaborator Author

sfirke commented Jul 16, 2019

It was easy to implement here: c27f1fb#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
Copy link
Collaborator Author

sfirke commented Jan 8, 2020

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

sfirke commented Feb 10, 2020

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

@sfirke
Copy link
Collaborator Author

sfirke commented Jun 17, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion needed enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant