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

as_factor () Error: `idx` must contain one integer for each level of `f` #89

antaldaniel opened this Issue Apr 19, 2017 · 1 comment


None yet
2 participants
Copy link

antaldaniel commented Apr 19, 2017

column <- c("hello", "dear", "hello", NA, "dear")
column <- forcats::as_factor (column)
Error: idx must contain one integer for each level of f

I think in this case three options could be considered:

  1. convert NA values to a factor with level = "NA";
  2. give a more meaningful error message;
  3. or just leave NA values as they are, to be consistent with as.factor () which handles NA values.

I think the third option is the best, but I do not see what other behavior may be considered.


This comment has been minimized.

Copy link

fabian-s commented Jul 14, 2017

seconded. this behavior makes the function near unusable for practical purposes....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment