I need some help in determining more than one minimum value in a vector. Let’s suppose, I have a vector x:
x<-c(1,10,2, 4, 100, 3)
and would like to determine the indexes of the smallest 3 elements, i.e. 1, 2 and 3. I need the indexes of because I will be using the indexes to access the corresponding elements in another vector. Of course, sorting will provide the minimum values but I want to know the indexes of their actual occurrence prior to sorting.
In order to find the index try this
This says that the first, third and sixth elements are the first three lowest values in your vector, to see which values these are try:
or just
If you have any duplicated value you may want to select unique values first and then sort them in order to find the index, just like this (Suggested by @Jeffrey Evans in his answer)