how to get 10th item from 2nd column in r

To get the 10th item from the 2nd column in R, assuming you have a data frame with at least two columns, you can use indexing and subsetting like this:

main.r
df <- data.frame(x = 1:20, y = 21:40)  # create a sample data frame
df[10, 2]  # get the 10th item from the 2nd column
119 chars
3 lines

This will return the value that is in the 10th row of the 2nd column of the df data frame. Note that the indexing in R starts at 1, so the 2nd column is referred to as 2 and not 1.

gistlibby LogSnag