Hi
r-help-bounces at r-project.org napsal dne 16.04.2009 15:23:15:
> Hi R,
>
> I have explored R archives a lot but couldn't find an efficient way of
> doing the following:
>
> I want to split a vector into sets of equal sizes. Is there any inbuilt
> function of doing so with the option of specifying how to treat the
> remaining observations. For example: suppose I want to split 20
> observations in 3 groups, then I also want the option to put the extra
> two observations into the 1st group or the last group or one in each
> group starting from 1st or starting from last.
>
> I have already tried the "cut" & the "quantcut"
function but of no use.
> Any help will be appreciated. Note that I am looking for an R function
> rather than lines of code.
Did you try split?
e.g.
split(rnorm(12), rep(1:3,4))
gives list with 3 vectors. Then you can use lapply, sapply or other list
functions to make some computation.
Or I could be completely wrong what you really want as you did not provide
any example.
Regards
Petr
>
> Regards
> Utkarsh
>
> ______________________________________________
> 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.