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

Support for factor labels with integer coded factors. #1498

Closed
ralmond opened this issue Jun 8, 2023 · 1 comment
Closed

Support for factor labels with integer coded factors. #1498

ralmond opened this issue Jun 8, 2023 · 1 comment

Comments

@ralmond
Copy link

ralmond commented Jun 8, 2023

I have a situation where there saved data in the csv file has integer codes for the factors, but I know the labels I want to use from the codebook.

I would think the way to specify this would be as follows

col_factor(c(Male=0,Female=1))

However, that throws an error.

Error: `levels` must be `NULL` or a character vector:
- `levels` is a 'numeric'

My intention is to feed the column into factor(x, levels=arg, labels=names(arg)), where arg is the argument to col_factor.

I think this would be a generally useful feature, as integer coding of factors (with external code book) is a common practice.

@hadley
Copy link
Member

hadley commented Jul 31, 2023

Thanks for filing this issue! Unfortunately, I think it's out of scope for this package: developing good software requires relentless focus, which means that we have to say no to many good ideas. Even though I'm closing this issue, I really appreciate the feedback, and hope you'll continue to contribute in the future 😄

@hadley hadley closed this as completed Jul 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants