Reputation: 10199
I have a basic question; how can I access the last element of specific column. in Matlab we can use end
to call the last element. I wonder how can i do it in R?
let's say:
df:
V1 V2
1 5
4 6
8 9
10 11
df[3:last_element,]
in matlab => df(3:end,:)
Upvotes: 0
Views: 179
Reputation: 886928
You can try nrow
df[3:nrow(df),]
# V1 V2
#3 8 9
#4 10 11
Or use tail
tail(df,1) #to get last row
As commented by @thelatemail, if you want to get the rows from 3:last_element using tail
tail(df,-2)
Upvotes: 4