[R] [:]

Alexy Khrabrov deliverable at gmail.com
Sat Nov 24 10:49:59 CET 2007


What are idioms for taking a head or a tail of a vector, either up to  
an index, or from an index to the end?  Also -- is it necessary to  
use length(v) to refer to the last element? E.g., Python has

v[:3] # indices 0,1,2
v[3:] # indices 3,4,...
v[-1] # the last element of v
v[:-1] # all but last

Cheers,
Alexy



More information about the R-help mailing list