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
G'day Utkarsh,
On Mon, 04 May 2009 11:51:21 +0530
utkarshsinghal wrote:
> 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*.
What do you mean by *nearly equal groups*? The size of the groups
should be nearly equal? The sum
check functions cut() and quantile(), and cut2() from package Hmisc;
maybe the following is close to what you want:
x <- sample(30, 52, replace = TRUE)
k <- 5 # how many groups
qs <- quantile(x, seq(0, 1, length.out = k + 1))
y <- cut(x, round(qs), include.lowest = TRUE)
y
table(y)
I hope it
lattice:::equal.count may be what you want.
2009/5/4 utkarshsinghal :
> 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
> observa
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 c
5 matches
Mail list logo