I think you misunderstood Richard's example. That does exactly what you want, i.e. first generate the indices and then select corresponding entires from the dataset. This is being done by indexing using `[`.
The reason it may appear that the final results are indices instead of elements because that example used 1, 2, ..., 400 as the dataset, where index values match element values. But the values printed at the end are essentially elements, and not indices.
So, the general idea is if you have a vector of actual data, say x, and a vector of indices, say i, x[i] should give you the elements you want.
Just to be clear, indexing will work only if your data is in R as well. If you generate indices in R, you can't directly use it on an Excel file. First you have to get the data in R, and then can do the subsetting.
Hope this helps.
P.S.
RStudio is nothing more than an IDE. The actual tasks are being handled by R, the programming language.