that is because your first object is a data.frame but when you transposed it you turned it into a matrix. so doing
> mat1 <- data.frame(matrix(rnorm(20*1532), ncol=20)) > mat2 <- t(mat1) > dim(sample(mat1, 5, replace=T)) [1] 1532 5 > dim(sample(mat2, 5, replace=T)) NULL > length(sample(mat2, 5, replace=T)) [1] 5 > dim(sample(as.data.frame(mat2), 5, replace=T)) [1] 20 5 It seems that all you want is to pick columns at random so why don't you just pick columns > mat1 <- matrix(rnorm(20*1532), ncol=20) > dim(mat1[, sample(1:20, 5, replace=T)]) [1] 1532 5 > dim(t(mat1)[, sample(1:1532, 5, replace=T)]) [1] 20 5 Jean On Thu, 10 Feb 2005, T. Murlidharan Nair wrote: > Just to explain my previous mail, here is the output I get. > > > > dim(tissue.exp) > [1] 1532 20 > > pick<-sample(tissue.exp,5,replace=TRUE) > > dim(pick) > [1] 1532 5 > > tissue.exp.t<-t(tissue.exp) > > dim(tissue.exp.t) > [1] 20 1532 > > pick<-sample(tissue.exp.t,5,replace=TRUE) > > dim(pick) > NULL > > -------- > Thanks ../Murli > > ______________________________________________ > [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 > ______________________________________________ [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
