[R] selecting matrix cels by two factors
    Dimitri Joe 
    dimitrijoe at gmail.com
       
    Sat Dec 17 00:02:24 CET 2005
    
    
  
Hi,
I have a (numeric) matrix X of the type
 > X <- matrix(c(1:9),ncol=3,nrow=3)
 > colnames(X) <- c("A","B","C")
 > rownames(X) <- c("D","E","F")
Also, a have a data frame Y like
 > Y <- as.data.frame(cbind(	c("D","E","F","D","E","F"),
+				c("A","C","A","B","B","C") ) )
I want a matrix like
1 4	  		 X["D","A"] X["D","B"]
8 5  or, equivalentely,  X["E","C"] X["E","B"]
3 9			 X["F","A"] X["F","C"]
Any suggestions?
Thanks in advanced,
Dimitri
    
    
More information about the R-help
mailing list