Skip to content
Prev 262969 / 398502 Next

Size argument in sample function

I am sure there is a more elegant version of doing this. But this works:

x<-rnorm(20)
y<-matrix(1:5) #number of points to sample
f<-function(z){sample(x,z)}
apply(y,1,f)

Just adjust y to your liking.

HTH,
Daniel
alfredo wrote:
--
View this message in context: http://r.789695.n4.nabble.com/Size-argument-in-sample-function-tp3605486p3606011.html
Sent from the R help mailing list archive at Nabble.com.