data.table
異なる操作で作成された 2 つの がありますが、値は同じです。ただし、出力が示唆するように、それらは異なる構造を持っています。
> 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
レベルの「キャプション」は構造上正しいため、要素を再レベル化せずにそれらを行う簡単な方法はありますか?
私が求めていることを明確にするために:私はこのような行動を期待しています。私は 2 つの data.tables/framesa
とb
. 両方とも、1->"bla"、2->"ble"、および1->"ble",2->"bla"にある変数x
を持っています。構造がであり、であるとしましょう。することでを手に入れたいのですが、私は を経験しています。factor
a
b
a$x
bla bla ble ble
b$x
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
提案をありがとう。