-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
bind_rows() silently converts factor to character #1485
Comments
Right. @hadley do we need a warning here ? |
> d1 <- head(iris, 1)
> d2 <- tail(iris, 1) %>% mutate(Species = as.character(Species))
> res <- bind_rows(d1,d2)
> str(res)
Classes ‘tbl_df’, ‘tbl’ and 'data.frame': 2 obs. of 5 variables:
$ Sepal.Length: num 5.1 5.9
$ Sepal.Width : num 3.5 3
$ Petal.Length: num 1.4 5.1
$ Petal.Width : num 0.2 1.8
$ Species : chr "setosa" "virginica" |
Yeah, we should be consistent wherever we do coercion. |
I think it would be nice to have a 'refactor' option on this function so that you get a new factor with levels from both of the previous data objects instead of a character vector, a choice of what to coerce to as it where. |
Hi @RichardJActon, Just a heads up: comments on old, closed issues have pretty low-visibility, and (depending on the package and age of the issue) may not be consistent with current versions. If this is something you think needs serious reconsideration, please open a new issue that follows the tidyverse guidelines. Thanks |
Hi @batpigandme Thanks for the heads up, This is more a suggested feature, the standard format for raising issues seems quite tailored for bug reports, are suggested features welcome via issues? Thought I'd raise it here in case someone who knew what they were talking about could shoot it down on grounds that would be inconsistent with some standard behaviour in the tidyverse, before I went any further with it. |
@RichardJActon, If you're reopening something for discussion, you should probably address whatever concerns were previously mentioned (speaking abstractly here). I recommend browsing through some of the existing issues with the feature label (here) to get a sense of what the maintainers ask for, etc. — I'd avoid using the ones submitted by the maintainers (e.g. hadley, krlmlr), as they tend not to follow form in the same way. |
Ah, I think I found an existing open issue to which this is applicable: #3278. Thanks for the help @batpigandme. |
This old issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with reprex) and link to this issue. https://reprex.tidyverse.org/ |
The joins issue a warning whenever they do this.
The text was updated successfully, but these errors were encountered: