Re: [R] permutation/randomization

2008-04-09 Thread Greg Snow
You can randomize the order (permute) of a single column with something like: > x <- cbind( x=1:10, y=101:110, z=201:210 ) > rownames(x) <- letters[1:10] > new.x <- x > new.x[,1] <- sample(new.x[,1]) > new.x x y z a 8 101 201 b 10 102 202 c 5 103 203 d 9 104 204 e 3 105 205 f 1 106 206

Re: [R] permutation/randomization

2008-04-09 Thread Philipp Pagel
On Wed, Apr 09, 2008 at 11:08:28AM -0700, Grant Gillis wrote: > I would like to randomize data within columns. I think the following line does what you want (minus preserving the row labels): apply(data, 2, sample) Maybe someone smarter than me knows how to preserve the row names. I would proba

Re: [R] permutation/randomization

2008-04-09 Thread Tobias Verbeke
Grant Gillis wrote: > Hello, > > I have what I suspect might be an easy problem but I am new to R and > stumped. I have a data set that looks something like this > > b<-c(2,3,4,5,6,7,8,9) > x<-c(2,3,4,5,6,7,8,9) > y<-c(9,8,7,6,5,4,3,2) > z<-c(9,8,7,6,1,2,3,4) > data<-cbind(x,y,z) > row.names(dat