Say I have a dataframe as follows:
A<-c(1,2,3,4)
B<-c(5,6,7,8)
C<-c(9,10,11,12)
data<-data.frame(A,B,C)
I know that I can subselect just rows 2 and 3 by the following:
data[2:3,]
My question is: how can I achieve the same by effectively saying "all rows with an index number greater than 1"? (I.e., the row indices for "data" are 1, 2, and 3. So, by requesting row indices ">1", I should get rows 2 and 3 only.)
>Solution :
You can use nrow to get the total rows and then use greater than operator.
data[1:nrow(data) > 1, ]
Also, for example if you need all indices greater than 2:
data[-c(1:2), ]