[R] How to extract every nth element from a vector

Uwe Ligges ligges at statistik.uni-dortmund.de
Wed Mar 28 17:33:09 CEST 2001



Barry Cooke wrote:
> 
> R-helpers:
> 
> Is there a simple way to extract every nth element from a very long vector?

vec[seq(n, length(vec), n)]


> [The vector I want to sample from is an object returned by lowess(). It is
> so long (11,628 pairs of elements) that it is causing non-R-related memory
> problems elsewhere. I don't see a better way other than sampling the output
> returned from lowess.]

Uwe Ligges
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list