我的数据框如下:
> t
Day TestID VarID
1 2013-04-27 Total Total
> str(t)
'data.frame': 1 obs. of 3 variables:
$ Day : Date, format: "2013-04-27"
$ TestID: factor [1, 1] Total
..- attr(*, "levels")= chr "Total"
$ VarID : Factor w/ 3 levels "0|0","731|18503",..: 3
当我尝试执行 rbind 时,出现以下错误
> rbind(t,t)
Error in NextMethod() : invalid value
但是当我尝试直接重新创建数据框时,我没有收到该错误:
> t <- data.frame(Day = as.Date("2013-04-27"),TestID = "Total", VarID = "Total")
> t
Day TestID VarID
1 2013-04-27 Total Total
> str(t)
'data.frame': 1 obs. of 3 variables:
$ Day : Date, format: "2013-04-27"
$ TestID: Factor w/ 1 level "Total": 1
$ VarID : Factor w/ 1 level "Total": 1
> rbind(t,t)
Day TestID VarID
1 2013-04-27 Total Total
2 2013-04-27 Total Total
谁能帮我弄清楚发生了什么以及如何避免这个错误。谢谢。