複雑なリストをデータフレームに変換する方法を徹底的に調べましたが、私の場合はかなりユニークです:「リストにリストされたデータポイント」リストの大きなリストをデータフレームに変換する
問題: 私は観測値(データポイント)がさらにリストとしてリストされているいくつかの変数のリストを持つLargeリストを持っています。
以下は、複数のプライマリリストの代表的なリスト1の構造です。
:List of 5 ..$ type : chr "time" ..$ data :List of 134 .. ..$ : int 5624 .. ..$ : int 5625 .. ..$ : int 5627 .. .. [list output truncated] :List of 5 ..$ type : chr "dist" ..$ data :List of 134 .. ..$ : num 22321 .. ..$ : num 22313 .. .. [list output truncated] :List of 5 ..$ type : chr "cad" ..$ data :List of 134 .. ..$ : num 0.4 .. ..$ : num 0.6 .. .. [list output truncated]
この構造は、このようにリストの多数のために複製される - の目的は、すべてにわたって、「タイプ」によって定義されたすべての変数の「データ」部分を引っ張ることによって、データフレームにこのリストを変換することですメジャーリスト
注:他のメジャーリストには、サブリストの変数($ type)と観測数の多いものがあります。つまり、134のリストはLargeリストの他のリストには適用されません。
ありがとうございます。 さらに更新:以下
は、明確にするためにdput結果である:
`
list(structure(list(type = "time", data = list(2881L, 2885L,
2892L, 2893L, 2898L, 2899L, 2900L, 2901L, 2904L, 2907L, 2911L,
2912L, 2914L, 2918L), series_type = "distance", original_size = 14L,
resolution = "high"), .Names = c("type", "data", "series_type",
"original_size", "resolution")), structure(list(type = "distance",
data = list(22512.4, 22548.3, 22605.5, 22615.1, 22670.3,
22692.2, 22705.8, 22719, 22752.3, 22771.7, 22815.6, 22827.9,
22851.6, 22892.5), series_type = "distance", original_size = 14L,
resolution = "high"), .Names = c("type", "data", "series_type",
"original_size", "resolution")), structure(list(type = "grade_smooth",
data = list(-1.7, -3.1, -3.7, -3.2, -3, -3, -1.4, -2.5, -3.2,
-3.6, -3.7, -3.6, -2.7, -2.5)9.7, 10.3, 10.5, 10),
series_type = "distance", original_size = 14L, resolution = "high"), .Names = c("type",
"data", "series_type", "original_size", "resolution")), structure(list(
type = "time", data = list(665L, 668L, 671L, 674L, 677L,
680L, 683L, 686L, 689L, 692L, 695L, 698L, 701L, 704L),
series_type = "distance", original_size = 14L, resolution = "high"), .Names = c("type",
"data", "series_type", "original_size", "resolution")))
` さらに更新:ソリューションの実装では、Iは、データフレーム等で終わる提供すると
これは:
DFの問題:
STR(unlisting)
List of 11106 $ :List of 5 ..$ type : chr "time" ..$ data : int [1:180] 2426 2429 2432 2435 2438 2441 2445 2448 2451 2454 ... ..$ series_type : chr "distance" ..$ original_size: int 180 ..$ resolution : chr "high" $ :List of 5 ..$ type : chr "distance" ..$ data : num [1:180] 8802 8815 8826 8834 8844 ... ..$ series_type : chr "distance" ..$ original_size: int 180 ..$ resolution : chr "high" $ :List of 5 ..$ type : chr "grade_smooth" ..$ data : num [1:180] -1 -0.7 -0.6 -0.4 -0.2 -0.1 0 0.2 0.4 0.5 ... ..$ series_type : chr "distance" ..$ original_size: int 180 ..$ resolution : chr "high" $ :List of 5 ..$ type : chr "velocity_smooth" ..$ data : num [1:180] 2.7 3.9 3.9 3.2 3.1 3.6 3.6 4.4 4.5 3 ... ..$ series_type : chr "distance" ..$ original_size: int 180 ..$ resolution : chr "high" $ :List of 5 ..$ type : chr "time" ..$ data : int [1:74] 2999 3008 3009 3016 3020 3026 3027 3029 3030 3036 ... ..$ series_type : chr "distance" ..$ original_size: int 74 ..$ resolution : chr "high" $ :List of 5 ..$ type : chr "distance" ..$ data : num [1:74] 23661 23719 23735 23790 23825 ... ..$ series_type : chr "distance" ..$ original_size: int 74 ..$ resolution : chr "high" $ :List of 5 ..$ type : chr "grade_smooth" ..$ data : num [1:74] -1.3 -0.5 -0.5 0.6 0.7 1 1 0.5 1 1.9 ... ..$ series_type : chr "distance" ..$ original_size: int 74 ..$ resolution : chr "high" $ :List of 5 ..$ type : chr "velocity_smooth" ..$ data : num [1:74] 5.7 6.2 7.4 8.9 8.2 8.6 8.2 8.3 8.2 9.2 ... ..$ series_type : chr "distance" ..$ original_size: int 74 ..$ resolution : chr "high" $ :List of 5 ..$ type : chr "time" ..$ data : int [1:60] 396 403 410 416 418 424 429 437 447 455 ... ..$ series_type : chr "distance" ..$ original_size: int 60 ..$ resolution : chr "high" $ :List of 5 ..$ type : chr "distance" ..$ data : num [1:60] 935 964 992 1014 1020 ... ..$ series_type : chr "distance" ..$ original_size: int 60 ..$ resolution : chr "high" $ :List of 5 ..$ type : chr "heartrate" ..$ data : int [1:60] 121 117 117 111 108 107 109 112 116 121 ... ..$ series_type : chr "distance" ..$ original_size: int 60 ..$ resolution : chr "high" $ :List of 5 ..$ type : chr "grade_smooth" ..$ data : num [1:60] -0.7 -0.5 -0.3 0.1 0.4 0.8 1 0.9 1.4 1.6 ... ..$ series_type : chr "distance" ..$ original_size: int 60 ..$ resolution : chr "high" $ :List of 5 ..$ type : chr "velocity_smooth" ..$ data : num [1:60] 3 4 4.1 3.8 3.4 2.8 3.4 5.2 6.2 6.7 ... ..$ series_type : chr "distance" ..$ original_size: int 60 ..$ resolution : chr "high" [list output truncated]
複雑なリストの例の部分を教えていただけますか?おそらく 'dput(mylist)'の結果を貼り付けるか、またはより小さなものを作ることによって? –
ネストされたリストについて言えば、リスト構造のすべての繰り返しの詳細を実際に知らなくても解決策になるのは本当に難しいことです。 –