[R] subsampling

Uwe Ligges ligges at statistik.uni-dortmund.de
Fri Jan 14 17:49:16 CET 2005


nicolas.deig at epfl.ch wrote:

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


Let's do a simple example:

x <- 1:3
v1 <- sample(x, 1)
# assume v1 = 2:
y <- x[-v1]
# now: y = c(1, 3)
v2 <- sample(y,1)
# assume v2 = 3, what happens now?
x <- y[-v2]


Uwe Ligges


> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html




More information about the R-help mailing list