Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
NA in levels vs NA in values #337
NA in levels vs NA in values #337
Changes from all commits
5f2027b
7db2914
8456e72
e62b172
2d2abfe
3318455
90705eb
b52d2bb
907b6c9
18d9611
d316919
bb8114d
b1e3f12
e65decc
1b0774f
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since
fct_recode()
disappeared does that mean this weirdness went away? #291 (comment)I was expecting to see a test for that or something
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added #339 to think about this more. I can't figure out if it deserves a test or not. On the one hand, it was arguably a bug, so it should get a test. On the other hand, thinking about
fct_collapse()
from first principles, it seems strange to test specific values ofother_level
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ability to specify the
na_level
that you wanted to materialize theNA
values as seems like it was probably useful?Maybe you can default
na_value = NA
infct_na_value_to_level()
, which makes that andfct_na_level_to_value()
reversible by default, while also allowing for alternate level names?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Take a look below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So if you already have an
NA
level, this will rename it tolevel
? Seems reasonableThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made this
extra_levels
because if you don't includeNA
, it's easy to create factors that have a mix of NAs in values and levels.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense. I was actually wondering if we even needed
extra_levels
at all, but there doesn't seem to be any other way to do this in forcats, so it seems useful to haveIt is a nice way of declaring, "no,
missing
should really be a missing value"There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm actually surprised this has never come up before. It seems pretty useful
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also added this new helper function to ensure that the implementation of "othering" is identical for all code paths.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.