Hi ,

what about split function ?
?split  divided x into 2 data.frame

a<-split(x,1:2)

a[[1]] first data frame
a[[2]] second data frame

regrads
M




Le 17/02/11 05:35, yf a écrit :
> I want to sample from the ID. For each ID, i want to have 2 set of data. I
> try the sample() function but it didn't work.
>
>> x<-data.frame(id=c(1,1,1,2,2,2,2,3,3,3,4,4), v1=c(1:12), V2=c(12:23))
>> x
>     id v1 V2
> 1   1  1 12
> 2   1  2 13
> 3   1  3 14
> 4   2  4 15
> 5   2  5 16
> 6   2  6 17
> 7   2  7 18
> 8   3  8 19
> 9   3  9 20
> 10  3 10 21
> 11  4 11 22
> 12  4 12 23


-- 
####################################
Mohamed Lajnef,IE INSERM U955 eq 15#
Pôle de Psychiatrie                #    
Hôpital CHENEVIER                  #
40, rue Mesly                      #
94010 CRETEIL Cedex FRANCE         #
mohamed.laj...@inserm.fr           #
tel : 01 49 81 31 31 (poste 18467) #
Sec : 01 49 81 32 90               #
fax : 01 49 81 30 99               #
####################################



        [[alternative HTML version deleted]]

______________________________________________
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.

Reply via email to