Is there a function to find the object with a maximum value in R [duplicate]

data(iris)

# return row with largest sepal length
iris[which.max(iris$Sepal.Length),]
#>     Sepal.Length Sepal.Width Petal.Length Petal.Width   Species
#> 132          7.9         3.8          6.4           2 virginica

# return `Species` from row with largest sepal length
iris[which.max(iris$Sepal.Length),"Species"]
#> [1] virginica
#> Levels: setosa versicolor virginica

Created on 2022-01-12 by the reprex package (v2.0.1)