Skip to content
Back to formatted view

Raw Message

Message-ID: <x2mzvcuf8t.fsf@biostat.ku.dk>
Date: 2005-01-14T16:50:26Z
From: Peter Dalgaard
Subject: subsampling
In-Reply-To: <1105719813.41e7f205d5319@imapwww.epfl.ch>

nicolas.deig at epfl.ch writes:

> hi,
> 
> I would like to subsample the array c(1:200) at random into ten subsamples 
> v1,v2,...,v10.

(Why are you c()'ing a single vector?)

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

That's not going to work (hint, the values contained in y do not
correspond to their indices).

I'd just do 

split(sample(1:200),rep(1:10,each=20))

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)             FAX: (+45) 35327907