我有一个data.table
由不同操作创建的两个 s,但值是相同的。但是,正如输出所示,它们具有不同的结构:
> str(resultstabledata)
Classes ‘data.table’ and 'data.frame': 234 obs. of 7 variables:
$ pT : Factor w/ 4 levels "Insignificant",..: 4 4 4 4 4 4 1 1 3 3 ...
$ shape : Factor w/ 2 levels "Base","Comparison": 1 1 1 1 1 1 1 1 1 1 ...
$ resid : chr "minzer" "minzer" "minzer" "minzer" ...
$ asset : Factor w/ 3 levels "crude","gold",..: 1 1 2 2 3 3 3 3 3 3 ...
$ base : Factor w/ 3 levels "mlp","elman",..: 1 1 1 1 1 1 1 1 1 1 ...
$ compared: Factor w/ 2 levels "arfima.roll",..: 1 2 1 2 1 2 1 2 1 2 ...
$ N : int 409 317 194 353 206 178 317 333 47 46 ...
- attr(*, ".internal.selfref")=<externalptr>
> str(a)
'data.frame': 7 obs. of 7 variables:
$ pT : Factor w/ 4 levels "Insignificant",..: 1 2 2 3 3 4 4
$ shape : Factor w/ 1 level "Comparison": 1 1 1 1 1 1 1
$ resid : Factor w/ 2 levels "minzer","diff": 1 1 2 1 2 1 2
$ asset : Factor w/ 1 level "crude": 1 1 1 1 1 1 1
$ base : Factor w/ 1 level "mlp": 1 1 1 1 1 1 1
$ compared: Factor w/ 1 level "lame": 1 1 1 1 1 1 1
$ N : num 0 0 0 0 0 0 0
有没有一种简单的方法可以rbind
对它们进行处理而不是重新调整因素,因为级别“标题”是通过构建对的?
澄清我在问什么:我期待这样的行为。我有两个 data.tables/framesa
和b
. 两者都有变量x
,factor
但在a
1->“bla”、2->“ble”和b
1->“ble”、2->“bla”中。让我们假设结构a$x
isbla bla ble ble
和b$x
is ble ble bla bla
。通过做merged <- rbind(a,b)
我想得到merged$x
的是bla bla ble ble ble ble bla bla
,但我正在经历merged$x
的是bla bla ble ble bla bla ble ble
。
感谢您的建议。