[R] cut a vector in equal parts

Patrick Burns pburns at pburns.seanet.com
Wed Feb 27 12:01:48 CET 2013

There is a discussion of the ways to do this
task (which can be trickier than it seems) at:



On 26/02/2013 17:39, Martin Batholdy wrote:
> Hi,
> I would like to cut a vector of values in parts.
> Each part should have an equal number of elements.
> for example:
> x <- (rnorm(500)^2)
> now I want 5 vectors each with 100 elements.
> The first vector should include the 100 lowest values of x and so on
> (so that the fifth vector contains the 100 highest values of x).
> thanks for any help!
> ______________________________________________
> R-help at 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.

Patrick Burns
pburns at pburns.seanet.com
twitter: @burnsstat @portfolioprobe
(home of:
  'Impatient R'
  'The R Inferno'
  'Tao Te Programming')

More information about the R-help mailing list