我有一个列表,其中包含带有标题的子列表(“双”对象)。我想从这些标头之一中引出值。
图像为列表: List with sublist
但这是这样的:
df list(3)
[1] result.1 double(2)
Number_cluster 2 double(1)
Value_index 3 double(1)
[2] result.2 double(2)
Number_cluster 6 double(1)
Value_index 1 double(1)
[3] result.3 double(2)
Number_cluster 5 double(1)
Value_index 6 double(1)
要提取的值为“ Number_clusters”
如果我可以从data.frame中提取这些值,那也会很有用
Data.frame:
[v1] [v2] [v3]
c(1,2,3) c(Number_clusters = 1, index= 2)
c(1,2,3) c(Number_clusters = 7, index= 7.4)
我尝试过
unique(rapply(b, function(x) head(b, )))
但这只给了我“ Number_clusters”和“ Index”这两个值,但是index对我没有用
dput输出:
list(result.1 = c(Number_clusters = 2, Value_Index = 7.0754),
result.2 = c(Number_clusters = 5, Value_Index = 7.142), result.3 = c(Number_clusters = 6, Value_Index = 11.235))