[R] Splitting a vector into equal groups

Uwe Ligges ligges at statistik.tu-dortmund.de
Tue May 5 14:12:56 CEST 2009

utkarshsinghal wrote:
> Hi All,
> I have vector of length 52, say, x=sample(30,52,replace=T). I want to 
> sort x and split into five *nearly equal groups*. Note that the 
> observations are repeated in x so in case of a tie I want both the 
> observations to fall in same group.
> This seems a very common task to do, but still I couldn't find an R 
> function to do this. Any help would be highly appreciated.

See ?cut for groups equal in in its range or
?co.intervals in package lattice for intervals somewhat equal in number 
of observations.

Uwe Ligges

> Regards
> Utkarsh
> 	[[alternative HTML version deleted]]
> ______________________________________________
> 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.

More information about the R-help mailing list