Skip to content
Prev 178086 / 398502 Next

transposing a matrix - row by row?

one way is the following:

X <- matrix(c(10,20,30,40,50,60), 2, 3,
     dimnames = list(c("1","2"), c("1","2","3")))

tX <- t(X)
cbind(
     rows = c(col(tX)),
     columns = c(row(tX)),
     entries = c(tX)
)


I hope it helps.

Best,
Dimitris
Dimitri Liakhovitski wrote: