语言R.使用数据框。
数据框用于跟踪篮球比赛得分。这些行代表不同的篮球队。其中一列代表本赛季的整体得分。
我如何选择得分最高的行(团队)?
答案 0 :(得分:1)
您可以使用which.max()
:
set.seed(1)
df = data.frame(team=letters[1:10],score=sample(1:10,10))
df[which.max(df$score),]
DF:
team score
1 a 3
2 b 4
3 c 5
4 d 7
5 e 2
6 f 8
7 g 9
8 h 6
9 i 10
10 j 1
输出:
team score
9 i 10