I need the minimum value for each rows from 2 matrix. The row names are common in both matrix but the column name changes.
eg:
matrix 1:
X <- matrix(runif(20), nrow=4)
rownames(X) <- paste0("Inst", seq(nrow(X)))
colnames(X) <- paste0("Ref", seq(ncol(X)))
matrix 2:
Y <- matrix(runif(20), nrow=4)
rownames(Y) <- paste0("Inst", seq(nrow(X)))
colnames(Y) <- paste0("Alt", seq(ncol(X)))
Expected result:
Minimum Id
Inst1 0.1275317 Ref15
Inst2 0.0006247 Alt4
Inst3 0.04583117 Ref13
Inst4 0.1111354 Alt5
I tried
t(apply(Y, 1, sort)[ 1, ])
t(apply(X, 1, sort)[ 1, ])
Yet don't know how to find the minimum from both matrix and tabulate separately as expected output file. Also I have duplicated rownames and colnames.
set.seed(1234)
) to ensure reproducibility of your expected output when using sample data based on random numbers. Otherwise there is no way to reproduce your expected output. – Maurits Evers