Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
in R Programming by (5.3k points)

a <- c(1, 2, 0, 3, 7)

I am looking for a function to return the index of the smallest value, 3. What is it?

1 Answer

0 votes

To return the index of the smallest value in a vector, you can use the which.min() function from the base package as follows



[1] 5

You can also use the which function from base R as follows:

which(v == min(v))

[1] 5

Browse Categories