0 votes
1 view
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
by (25.4k points)

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

Welcome to Intellipaat Community. Get your technical queries answered by top developers !