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

Thomas Lumley tlumley at u.washington.edu
Wed Mar 28 17:31:55 CEST 2001


On Wed, 28 Mar 2001, Barry Cooke wrote:

> R-helpers:
>
> Is there a simple way to extract every nth element from a very long vector?
>
> [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.]

seq(1,11628,length=1000) will give 1000 evenly spaced numbers from 1:11628
that you can then index with.

	-thomas


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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