Skip to content
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

Unexpected (?) behaviours when using bind_rows() on different classes #1538

Closed
LeoRoth opened this issue Nov 16, 2015 · 0 comments
Closed

Unexpected (?) behaviours when using bind_rows() on different classes #1538

LeoRoth opened this issue Nov 16, 2015 · 0 comments
Assignees
Milestone

Comments

@LeoRoth
Copy link

@LeoRoth LeoRoth commented Nov 16, 2015

Bind_rows() behaves differently when used on columns of class numeric and factor or integer and factor. In the first case it converts the resulting column into numeric and in the second it fails. It is even more confusing that both behaviours are different than when using rbind(). In my opinion the rbind() option (converting to character) is the most appropriate. Thank you deeply for all you work anyway!

library(dplyr)

df1 <- data.frame(a=c(1,2), b=c(1,2))
df2 <- df1
df2$b <- as.integer(df2$b)
df3 <- data.frame(a=c(1,2), b=c(1,'q'))

# column b is numeric in df1, integer in df2 and factor in df3
bind_rows(df1, df3)
bind_rows(df2, df3)

rbind(df1, df3)
rbind(df2, df3)
@romainfrancois romainfrancois self-assigned this Nov 18, 2015
@romainfrancois romainfrancois added this to the 0.5 milestone Nov 18, 2015
@lock lock bot locked as resolved and limited conversation to collaborators Jun 9, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants