Re: [R] use the value of variable to quote certain elements in matrix

2009-04-07 Thread Luc Villandre
Hi Weicheng, Did you forget to add " " to index your elements? The following example works perfectly fine. test.matrix = matrix(1:4,nrow=2) ; rownames(test.matrix)=c("hi1","hi2") ; colnames(test.matrix)=c("bye1","bye2") ; test.matrix bye1 bye2 hi113 hi224 test.matrix["hi1"

[R] use the value of variable to quote certain elements in matrix

2009-04-07 Thread weicheng wang
Hi, I want to use the value of variable to quote elements in matrix. For example, I have a matrix like:               y1   y2m1         1      2m2         3      4 where y1,y2,m1,m2 are column and row names.  I have two random character variable, say x,  that could be either  y1 or y2  and  y that