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 PM, yf <chang648@umn.edu> wrote:

>
> 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)
> I tried to random select the one unique case so I have one group.
>
>  id v1 V2
>
> 2  1  2 10
>
> 4  2  4 12
>
> 6  3  6 14
> 7  4  7 15
> How to get the rest of data in other group?
>
> --
> View this message in context:
> http://r.789695.n4.nabble.com/split-the-data-tp3321985p3321985.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help@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.
>

	[[alternative HTML version deleted]]

