[R] subsampling
Romain François
francoisromain at free.fr
Fri Jan 14 17:52:23 CET 2005
nicolas.deig at epfl.ch a écrit :
>hi,
>
>I would like to subsample the array c(1:200) at random into ten subsamples
>v1,v2,...,v10.
>
>I tried with to go progressively like this:
>
>
>
>
>>x<-c(1:200)
>>v1<-sample(x,20)
>>y<-x[-v1]
>>v2<-sample(y,20)
>>
>>
>
>and then I want to do:
>
>
>
>>x<-y[-v2]
>>
>>
>Error: subscript out of bounds.
>
>__
>
You should try :
x[-c(v2,v1)]
But more accurately, try permutting the all x and choose the 20 firsts
entries, the 20 after, ...
I think that will do the job
x <- 1:200
y <- x[sample(200)]
v1 <- y[ 1:20]
v2 <- y[21:40]
...
Regards.
Romain.
--
Romain FRANCOIS : francoisromain at free.fr
page web : http://addictedtor.free.fr/ (en construction)
06 18 39 14 69 / 01 46 80 65 60
_______________________________________________________
Etudiant en 3eme année
Institut de Statistique de l'Université de Paris (ISUP)
Filière Industrie et Services
http://www.isup.cicrp.jussieu.fr/
More information about the R-help
mailing list