[R] Strange result from single [] extract operator
rafael.7 at poczta.fm
rafael.7 at poczta.fm
Sat Sep 28 17:18:12 CEST 2013
Hi All,
I am using Rx64 3.0.1 on Windows 7 x64, and wanted to get two last rows from dataset. First, I tried
library(datasets)
> data<-airquality
> data[nrow(data)-1:nrow(data),]
and received 152 rows sorted desc. Could you explain why it worked this way? I changed the extract line to:
data[(nrow(data)-1):nrow(data),]
and then I received what I wanted but still am curious about the performance of my previous code.
Yours faithfully,
Rafał
More information about the R-help
mailing list