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
I found that a dataframe character vector when row binded consistently was converted to numbers. It turns out that rbind and rbind.fill behave differently (seems to be unwanted behaviour):
library(plyr)
d1 <- data.frame(a=NA, b=NA)
d2 <- data.frame(a="A", b=1)
rbind(d1, d2)
a b
1 <NA> NA
2 A 1
and different results for rbind.fill
rbind.fill(d1, d2)
a b
1 NA NA
2 1 1
which is different from standard vector type casting which gives
c(NA, "A")
NA "A"
The same occurs for zero column data frames:
d3 <- data.frame(a=integer(), b=integer())
rbind(d3, d2)
a b
1 A 1
rbind.fill(d3, d2)
a b
1 1 1
c(integer(), "A")
[1] "A"
If the type is the same, the results are the same:
d3 <- data.frame(a=character(), b=integer())
rbind(d3, d2)
a b
1 A 1
rbind.fill(d3, d2)
a b
1 A 1
The text was updated successfully, but these errors were encountered:
uups, of course, my mistake. TIL: do not work late night. okay, so rbind.fill handling is more in line with standard type R casting than rbind as c(NA, factor("A")) gives > NA 1. Thanks!
I found that a dataframe character vector when row binded consistently was converted to numbers. It turns out that
rbind
andrbind.fill
behave differently (seems to be unwanted behaviour):and different results for
rbind.fill
which is different from standard vector type casting which gives
The same occurs for zero column data frames:
If the type is the same, the results are the same:
The text was updated successfully, but these errors were encountered: