I'm trying to order a data set using the following:
library(dslabs)
data(murders)
pop<- murders$population
pop_min_index <- order(pop)
min(pop_min_index)
When I use this, R presents "pop_min_index" as all the values from the data set, when I just want the first value, i.e. the answer should be "51", where as my result is coming out as "51, 9, 46, 35, 2, 42", etc.
I've tried using:
min(pop_min_index)
but this doesn't seem to work either
Does anyone know what is wrong my code?
Thanks