I have a matrix with column names and a vector of names in a different order.
Matrix column names:
c("colname1", "colname2", "colname3", "colname4", "colname5")
Vector of names:
c("colname4", "colname3", "colname2", "colname5", "colname1")
I am trying to order the matrix columns in the same order as the names in the vector.
I have tried:
test <- match(colnames(matrix1), colnames(matrix2))`
but it didn't work. Do you know any alternative?