On Tue, 24 Nov 2009 10:14:18 -0500 Sarah Goslee <sarah.gos...@gmail.com> wrote: > x <- runif(45) # make a test vector > length(x) # position of the last element > x[length(x)] # value of the last element
For the last one, this should be even better: tail(x, 1) But, actually benchmarking this, it turns out that the 'length' solution is about 10 times faster than the 'tail' solution. :-( -- Karl Ove Hufthammer ______________________________________________ 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.