Can someone suggest a method to print multiple matrices side by side in a terminal window.
For the matrices m1 and m2 I would like to get the desired result below.
m1 <- m2 <- matrix(1:4, nrow=2, dimnames=list(c("a", "b"), c("d", "e")))
Required conclusion
m1 m2 dede a 1 3 a 1 3 b 2 4 b 2 4
The reason is because I have several 2x2 matrices that I use in my calculations and want to show in the Rmarkdown document. This takes up too much of the page when printing length paths. Thank you
EDIT
My attempt to solve
fn <- function(x) setNames(data.frame(.=paste(" ", rownames(x)), x, check.names=F, row.names=NULL),c(paste(substitute(x)), colnames(x))) cbind(fn(m1), fn(m2)) # m1 de m2 fg #1 a 1 3 v 1 3 #2 b 2 4 w 2 4
But this, of course, is not very good.
source share