在数据帧DF(由两个列排序),我必须先选择一个行,其中两个> 7和从四个列中提取它的数据:
one two three four
[1,] 1 6 11 16
[2,] 2 7 12 17
[3,] 3 8 11 18
[4,] 4 9 11 19
[5,] 5 10 15 20
基本上我需要这一行:
[3,] 3 8 11 18
这是一个使用选项 which.max
df[which.max(df$two > 7), ]
# one two three four
#3 3 8 11 18
df <-read.table(text =
"one two three four
1 6 11 16
2 7 12 17
3 8 11 18
4 9 11 19
5 10 15 20", header = T)
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句