-
Notifications
You must be signed in to change notification settings - Fork 127
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
the output of fct_collapse(..., `group_other = TRUE) seems wrong order. #219
Comments
I agree, also encountered this problem. For the maintainers: since I'm not deep enough in the code to fix it myself and don't really have the time to test this, but Instead of
something like this (maybe with the conditional moved to the top of the function?)
|
Sorry if this is unrelated, but I figured it would be better to ask here first before opening a new issue:
|
Weirdly enough, I remember seeing this a while ago, in #172 , and #202 . We see it "fixed" (as of 0.4.0, according to the changelog apparently ) here: 34ad9e5#diff-8312ad0561ef661716b48d09478362f3 Lines 1 to 13 in 34ad9e5
That change was pushed in september, however, and the cran release of forcats 0.4.0 was: 2019-02-17 . My version of forcatsIf examine my install of > packageVersion("forcats")
[1] ‘0.4.0.9000’ If I probe into the changelog, I notice that it is apparently "fixed" > system.file("NEWS.md", package = "forcats") %>% readLines() %>% cat(sep = "\n") State of NEWS.md for my installed version of forcatsforcats (development version)
forcats 0.4.0New features
|
This is a weirdly hard bug to reproduce - I get the same (incorrect) output when I run @cuttlefish44 's reprex, but when I try to reproduce this with other examples, they sometimes work correctly |
Moving the bullet point referencing tidyverse#172 and tidyverse#202, as it was put under 0.4.0 heading by mistake -- it was not part of that release. Raised in issue tidyverse#219.
@cuttlefish44 @xjlc @mjanson: this bug is fixed in the development version of library(forcats)
packageVersion("forcats")
#> [1] '0.4.0.9000'
factor_vec <- as.factor(LETTERS[c(5,1,2,4,3)])
a <- fct_collapse(factor_vec,
BD = c("B", "D"),
ACE = c("A", "C", "E"))
b <- fct_collapse(factor_vec,
BD = c("B", "D"),
AC = c("A", "C"),
group_other = TRUE)
data.frame(origin = factor_vec, all_lev_named = a, with_group_other = b)
#> origin all_lev_named with_group_other
#> 1 E ACE Other
#> 2 A ACE AC
#> 3 B BD BD
#> 4 D BD BD
#> 5 C ACE AC Created on 2020-01-21 by the reprex package (v0.3.0) You can install as follows:
@mstr3336 As you can see, I get the correct output using |
When I use
fct_collapse
withgroup_other = TRUE
, the output are not in correct order. Is this by design ?Created on 2019-11-08 by the reprex package (v0.3.0)
The text was updated successfully, but these errors were encountered: