# Redefining and merging two tables in R or SAS

I have two tables (matrix) of same dimensions, one contains correlation coefficients and other with p values. I want to combine them into one table. For example let's say I have correlation coefficient between variable A1 and A2 of 0.75 in table 1 and p value of 0.045 in table 2. Now in my combined table 3, I want to use:

condition1 for table 1: if a coefficient value in a cell of table 1 is less than 0.4 then "+", 0.4 <= coefficient <0.7 then "++" else "+++",

condition2 for table 2: if a pvalue in a cell of table 2 is less than 0.01 then "+++", 0.01 <= pvalue < .05 then "++" else "+".

Thus corresponding cell value for A1 and A2 in table 3 should look like: +++/++ where "+++" correspond to table 1 value of 0.75 and ++ correspond to table 2 p value of 0.045 and "/" is just a separator.

I would like to do this either is SAS or R. Thanks in advance.

• There is not much statistics in your question, so perhaps better suited for Stack Overflow... but what the hell, I'll answer anyway. Sep 22 '11 at 15:06

I think this should come close in R (untested since you did not provide data):

t1val<-ifelse(T1<0.4, "+", ifelse(T1<0.7, "++", "+++"))
t2val<-ifelse(T2<0.01, "+", ifelse(T2<0.05, "++", "+++"))

t3<-paste(t1val, t2val, sep="/")
t3<-array(t3, dim=dim(t1))


Basically, you treat the original matrices as vectors and then at the end convert the result back.

• thanks, so t3<-paste(t1val, t2val, sep-"/") right? Sep 22 '11 at 15:18
• Check out the symnum function - it can save a lot of ifelses. Sep 22 '11 at 16:12