我有以下形式的列表列表:
[[1]]
[[1]][[1]]
[1] 0.4
[[2]]
[1] 0.3
[[3]]
[1] 9
[[4]]
[1] 10
[[5]]
[1] 0.4
[[2]]
[[2]][[1]]
[1] 0.4
[[2]]
[1] 0.4
[[3]]
[1] 99
[[4]]
[1] 4
[[5]]
[1] 3
[[3]]
[[3]][[1]]
[1] 0.3
[[2]]
[1] 0.3
[[3]]
[1] 2
[[4]]
[1] 08
[[5]]
...
[[100]]
[[100]][[1]]
[1] 0.4
[[2]]
[1] 0.1
[[3]]
[1] 0
[[4]]
[1] 7
[[5]]
我想选择所有包含 0.4 的列表[[i]][[1]]
。
也就是说,选择
[[i]][[1]]==0.4
结果将是:
[[1]]
[[1]][[1]
[1] 0.4
[[2]]
[1] 0.3
[[3]]
[1] 9
[[4]]
[1] 10
[[5]]
[1] 0.4
[[2]]
[[2]][[1]]
[1] 0.4
[[2]]
[1] 0.4
[[3]]
[1] 99
[[4]]
[1] 4
[[5]]
[1] 3
...
[[100]]
[[100]][[1]]
[1] 0.4
[[2]]
[1] 0.1
[[3]]
[1] 0
[[4]]
[1] 7
[[5]]
这可以在没有for
循环或其他东西的情况下完成吗?
我尝试选择[[i]][[1]]==0.4
,但它只返回真实条件。如果我想根据多个条件进行选择怎么办?例如,[[i]][[1]]==0.4 & [[i]][[2]]==0.9