Skip to content
Prev 174835 / 398502 Next

Converting a Matrix to a Vector

try this:

set.seed(1)
m <- matrix(runif(5^2), nrow = 5,
     dimnames = list(c("A","B","C","D","E"), c("O","P","Q","R","S")))

v <- c(m)
names(v) <- paste(rownames(m), colnames(m)[col(m)], sep = ".")
# or
# names(v) <- outer(rownames(m), colnames(m), paste, sep = ".")
v


I hope it helps.

Best,
Dimitris
Ken-JP wrote: