title: R - fastest way to get the indices of the max n elements in a vector
body: <p>Suppose I have a huge vector <code>x</code> with 1 million elements, and I would like to find the indices of the maximum 30 elements. I don't particularly care whether the results are sorted among these 30 elements, as long as they are the max 30 out of the entire vector. Using <code>order[x][1:30]</code> seems quite expensive since it has to sort the entire vector. I thought about utilizing the <code>partial</code> option in <code>sort</code>, but <code>sort</code> returns the values and the <code>index.return</code> option is not supported when <code>partial</code> is specified. Is there an efficient way to find the indices without sorting the entire vector?</p>