Skip to content
Prev 166644 / 398502 Next

Converting Numerical Matrix to List of Strings

one way is the following:

mat <- matrix(sample(0:3, 12, TRUE), 4, 3)
strg <- c("a", "c", "g", "t")

out <- strg[mat + 1]
dim(out) <- dim(mat)
apply(out, 1, paste, collapse = "")


I hope it helps.

Best,
Dimitris
Gundala Viswanath wrote: