On 18/06/09 04:16, onyourmark wrote:
Hi. I have an object. I think it is a list.
It is a matrix

corTFandPCA <- runif(922*5)
dim(corTFandPCA) <- c(922,5)
dimnames(corTFandPCA) <- list(paste("abdomen",2:923,sep="."), paste("PC",1:5,sep=""))
str(corTFandPCA)
#  num [1:922, 1:5] 0.17 0.285 0.388 0.995 0.211 ...
#  - attr(*, "dimnames")=List of 2
#   ..$ : chr [1:922] "abdomen.2" "abdomen.3" "abdomen.4" "abdomen.5" ...
#   ..$ : chr [1:5] "PC1" "PC2" "PC3" "PC4" ...


I want to order it according to PC1.

I tried this

  dfCorTFandPCA=as.data.frame(corTFandPCA)
orderedCorTFandPCA=dfCorTFandPCA[order(PC1)]

Try

corTFandPCA[order(corTFandPCA[,"PC1"]),]

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

Reply via email to