Adjust the columns of the input matrix same as in the reference matrix
We adjusted the columns of the input matrix to have the same ordering as in the reference matrix.
AdjustMatrix(reference, input)
reference
: The reference matrix.input
: The input matrix.Matrix
Md Bahadur Badsha (mbbadshar@gmail.com)
# Reference matrix reference <- matrix(0,nrow=4,ncol = 4) colnames(reference) <- c("V1","T1","T2","T3") rownames(reference) <- colnames(reference) # Adjacency matrix for reference reference[1,2] <- 1 reference[2,3] <- 1 reference[3,4] <- 1 # Input matrix input <- matrix(0, nrow = 4, ncol = 4) colnames(input) <- c("V1","T2","T3","T1") rownames(input) <- colnames(input) # Adjacency matrix for input input[1,2] <- 1 input[2,3] <- 1 input[3,4] <- 1 AdjustMatrix <- AdjustMatrix (reference, input)
Useful links