I would like to identify which coordinate of my vector gives me the greatest value. For a simple example suppose that:
x <- c(10,22,20,18,5)
First, find the greatest value with max:
> max(x) [1] 22
From there, you can figure out which value(s) in the vector match the greatest value:
> x==max(x) [1] FALSE TRUE FALSE FALSE FALSE
which() can be used to translate the boolean vector into indices:
which(x==max(x)) [1] 2