On 31 Jan 2008, you wrote in gmane.comp.lang.r.general: > Hi, > > sample(x) only permutates and/or samples from a vector, which I > can't use for a matrix. Please help.
You just feed sample(.) a "redimensioned" object. If you need to do it programmatically just multiply the dimensions of the matrix to create a length for the working vector. > xm<-rnorm(25) > xmtx<-matrix(xm,dim<-c(5,5)) > samp<-sample(as.matrix(xmtx,dim<-c(1,25))) > samp #output of 25 numbers elided > samp<-sample(as.matrix(xmtx,dim<-c(1,25)),10) > samp [1] 0.26421745 0.63888288 1.06176705 -1.56074510 -0.72471549 - 0.38743020 [7] -0.68765683 1.18081648 -1.51566762 0.07560708 -- David Winsemius ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.