に、これはすべてのリストから最初の列は、データを対応する、それに応じて転置されるべきであり、このトランスポーズリストの行データフレーム
level1 level2 level3 level4 level5 level6 level7
1) 18 abc NA pqr lmn NA NA
2) 20 xyz hive NA foo bar NA
3) 22 NA dark yellow foobar blue NA
4) 24 dvd dxs NA glass while though
のようなO/Pの何かを期待
lst=list(structure(c("level1", "level2", "level4", "level5","18", "abc", "pqr", "lmn"),
.Dim = c(4L, 2L)),
structure(c("level1", "level2", "level3", "level5", "level6", "20", "xyz", "hive", "foo", "bar"),
.Dim = c(5L, 2L)),
structure(c("level1", "level3", "level4", "level5","level6", "22", "dark", "yellow","foobar", "blue"),
.Dim = c(5L, 2L)),
structure(c("level1", "level2", "level3", "level5","level6","level7","24", "dvd", "dxs","glass", "while","though"),
.Dim = c(6L, 2L))
)
私のリスト構造であると仮定彼らの行を見上げる必要があります。コラム自体与えるエラーも
apply(list_temp,1,function(x){list_temp[[x]][,1]})
で試してみました
unique(t(list_temp[[c(1,2)]][,1]))
ERROR:Error in list_temp[[c(1, 2)]][, 1] : incorrect number of dimensions
にすべての行の転置をやろうとしている。しかし
は私に
Error in apply(list_temp, 1, function(x) { :
dim(X) must have a positive length
を与え、それがどうあるべきか上の任意の提案完了しました。
ありがとうございました。
... + 1 !!! – deepesh
あなたのコードにいくつかのバグがあると思います。もし2つではなく4つのリストレコードを持っていれば、正しい出力は得られません。 – deepesh
@deepesh質問にあなたの問題を再現する例を追加(追加)できますか? – Jaap