On Jan 24, 2013, at 4:23 PM, hp wan wrote: > Hi all mailing listers, > > I wanna get the last several elments of vector. > e.g. x <- c(1,2,3,.....,78, 79, 80) > > How can I implement to assign last three elements to y, y <- c(78, 79, 80) > ?
?tail > In Matlab, It can easily achieve by y=x(end-2:end) y <- tail(x, 3) -- David Winsemius Alameda, CA, USA ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.