-
Notifications
You must be signed in to change notification settings - Fork 418
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
gather converts non-gathered factors to integers #104
Comments
I assume this is a bug since |
I see the same thing (tidyr 0.3.0 + R 3.2.1/3.2.2). |
Same thing happens on Mac (R 3.2.2). Seems I missed this when testing the pre-release version of tidyr ## with tidyr 0.3
tab <- structure(list(variable = structure(1:5, .Label = c("price", "carat", "depth", "table", "x"), class = "factor"), mean = c(3907.186,
0.794283333333333, 61.7526666666667, 57.4653333333333, 5.72182333333333
)), class = c("tbl_df", "tbl", "data.frame"), row.names = c(NA,
-5L), .Names = c("variable", "mean"))
tab %>% gather("function", "value", -1)
tab %>% gather("function", "value", -variable)
## with tidyr 0.2
tab %>% gather("function", "value", -1)
Source: local data frame [5 x 3]
variable function value
(fctr) (fctr) (dbl)
1 price mean 3907.1860000
2 carat mean 0.7942833
3 depth mean 61.7526667
4 table mean 57.4653333
5 x mean 5.7218233 |
same with the dev version 0.3.0.9000 :( devtools::install_version("tidyr", version = "0.2.0", repos = "http://cran.us.r-project.org") works again |
@ckluss Try the last commit for version 0.2.0 devtools::install_github("hadley/tidyr", ref = "2e08772d154babcc97912bcae8b0b64b65b964ab") |
That works. Thanks @hadley |
cool, thank you very much for the fast fix @hadley |
When gathering a number of columns in a data frame, the format of ungathered columns should remain unaffected, but it appears that ungathered factor columns are converted to integers with tidyr 0.3.0 (I use vanilla R 3.2.2 under Ubuntu 14.04).
Create example data
Gather and inspect
The text was updated successfully, but these errors were encountered: