So now I know that I have to choose the observations 267th, 270th, 374th, 107th, etc., of my variable.
My question is, is there a way in Rstudio Cloud to choose those 20 specific observations to create a vector of them without having to look in my entire 400 data to identify the data number to record it manually in a vector? Like an automatic way?
Thanks for replying but you gave me the same I have. Those are the positions of my data sample in the whole data set. Like I want Rstudio to give me a list of the data that represent (following your output) the position 59th, 8th, 381th, 367th, 294th, 335th,etc. in the whole data set. Because if not I have to go in Excel over the 400 items, and select, copy, paste, 20 times to get my sample of those specific items positions to then upload my sample data set to Rstudio to be able to work. I was wondering if there is an easiest way than that.
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.