Question: Order data matrix as in other data matrix


Order data matrix as in other data matrix

Answers 0
Added at 2016-12-26 13:12

I have 3 very big data matrices (where row names are chemical compounds and column names are treatments). They contain other values (1st: absolute concentrations, 2nd p-values, 3rd: asterisks) but they are not ordered in the same way. I have to order them all the same (rows and columns) because data.frame2 and 3 have to be superimposed on a heat map made from data.frame 1.

I tried to use sort function but I want to order the 2nd and 3rd data frame as in the 1st one.

I have to find something that works as:

data.frame2 <- data.frame2[,]
data.frame3 <- data.frame3[,]

The dimensions are the same and also row and column names are the same as I used:

colnames(data.frame2) <- (colnames(data.frame1))
colnames(data.frame3) <- (colnames(data.frame1))
row.names(data.frame2) <- (row.names(data.frame1))
row.names(data.frame3) <- (row.names(data.frame1))

To be sure.

PS: it is almost impossible to list all rownames or column names our use their indices because they are (like I said) very big dataframes.

Source Show
◀ Wstecz