1
我有一個數據幀列表(列表9)。R:從列表中提取一個值並將其粘貼到數據幀中
> str(list9)
List of 2
$ :'data.frame': 64 obs. of 11 variables:
..$ list$Stimulus : Factor w/ 7 levels "108.wav","42.wav",..: 1 1 1 1 1 1 1 1 2 2 ...
..$ list$IndicationStandard: num [1:64] 1 0 1 0 1 0 0 0 0 0 ...
..$ list$P42 : num [1:64] 0 0 0 0 0 0 0 0 0 0 ...
..$ list$P53 : num [1:64] 0 0 0 0 0 0 0 0 0 0 ...
..$ list$P64 : num [1:64] 0.375 0.375 0.375 0.375 0.375 0.375 0.375 0.375 0.375 0.375 ...
..$ list$P75 : num [1:64] 0.812 0.812 0.812 0.812 0.812 ...
..$ list$P86 : num [1:64] 0.75 0.75 0.75 0.75 0.75 0.75 0.75 0.75 0.75 0.75 ...
..$ list$P97 : num [1:64] 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 ...
..$ list$P108 : num [1:64] 0.375 0.375 0.375 0.375 0.375 0.375 0.375 0.375 0.375 0.375 ...
..$ list$TGdispInd1 : num [1:64] 0.317 0.317 0.317 0.317 0.317 ...
..$ list$TGdispInd2 : num [1:64] 0.756 0.756 0.756 0.756 0.756 ...
$ :'data.frame': 64 obs. of 11 variables:
..$ list$Stimulus : Factor w/ 7 levels "108.wav","42.wav",..: 1 1 1 1 1 1 1 1 2 2 ...
..$ list$IndicationStandard: num [1:64] 0 0 1 0 1 0 0 0 0 0 ...
..$ list$P42 : num [1:64] 0 0 0 0 0 0 0 0 0 0 ...
..$ list$P53 : num [1:64] 0 0 0 0 0 0 0 0 0 0 ...
..$ list$P64 : num [1:64] 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 ...
..$ list$P75 : num [1:64] 0.812 0.812 0.812 0.812 0.812 ...
..$ list$P86 : num [1:64] 0.75 0.75 0.75 0.75 0.75 0.75 0.75 0.75 0.75 0.75 ...
..$ list$P97 : num [1:64] 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 ...
..$ list$P108 : num [1:64] 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 ...
..$ list$TGdispInd1 : num [1:64] 0.351 0.351 0.351 0.351 0.351 ...
..$ list$TGdispInd2 : num [1:64] 0.784 0.784 0.784 0.784 0.784 ...
我創建了一個目標的數據幀(結果)
> str(result)
'data.frame': 2 obs. of 3 variables:
$ TGdispInd1: num 0 0
$ TGdispInd2: num 0 0
$ subject : chr "TG_75ms_Step11_V1-998-1.txt" "TG_75ms_Step11_V1-999-1.txt"
我想列表中的每個數據幀的列表$ TGdispInd1和列表$ TGdispInd2的第一值粘貼到數據幀「結果」(也可能是列表$ TGdispInd1和列表$ TGdispInd2的均值,因爲所有64個值都相等)。
這是得到的數據幀應該怎麼看起來像
> result
TGdispInd1 TGdispInd2 subject
1 .317 .756 TG_75ms_Step11_v1-998-1.txt
2 .351 .784 TG_75ms_Step11_v1-999-1.txt
是否有人知道如何做到這一點?
它完美,謝謝! – piptoma