> From: [EMAIL PROTECTED]
> 
> 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)

This only worked because your original data happens to be the same as the
indices (1:200).  The next round failed because that's not true any more.

> and then I want to do:
> 
> >x<-y[-v2]
> Error: subscript out of bounds.

Can you explain more explicitly what you mean by subsamples?  Here you're
trying to overwrite the original data by sampling from the subsample, which
doesn't seem like what you said you want.

If you simply want to randomly divide 1:200 into 10 sets, try something
like:

x.sample <- matrix(sample(x), ncol=10)

where x.sample is a matrix with 10 columns, each column containing a random
(but disjoint) part of x.

Andy

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

Reply via email to