You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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<-df1df2$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)
The text was updated successfully, but these errors were encountered:
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!
The text was updated successfully, but these errors were encountered: