Hi:
Is this what you want?
x$gpvar <- rep(c(1, 2), 4)
split(x, x$gpvar)
$`1`
id v1 V2 gpvar
1 1 1 9 1
3 2 3 11 1
5 3 5 13 1
7 4 7 15 1
$`2`
id v1 V2 gpvar
2 1 2 10 2
4 2 4 12 2
6 3 6 14 2
8 4 8 16 2
HTH,
Dennis
On Wed, Feb 23, 2011 at 5:16 P
x<-data.frame(id=c(1,1,2,2,3,3,4,4), v1=c(1:8), V2=c(9:16))
> x
id v1 V2
1 1 1 9
2 1 2 10
3 2 3 11
4 2 4 12
5 3 5 13
6 3 6 14
7 4 7 15
8 4 8 16
1)
I want to split the data into 2 group with one unique ID. I should use the
split function but i don't know how to write it out.
2
2 matches
Mail list logo