Hi guys, I have a question about the function print(). Actually, I'm learning how to create a matrix, but I don't find how to print some matrix at the same time.
y <- matrix(1:20, nrow = 5, ncol = 4)
cells <- c(1, 26, 24, 68)
rnames <- c('R1', "R2")
cnames <- c('C1', 'C2')
mymatrix1 <- matrix(cells, nrow = 2, ncol = 2, byrow = TRUE, dimname = list(rnames, cnames))
mymatrix2 <- matrix(cells, nrow = 2, ncol = 2, byrow = FALSE, dimname = list(rnames, cnames))
#of course I can do it with three print functions, but it's not convenient.
print(y)
print(mymatrix1)
print(mymatrix2)
#here is the problem, if I separate them with commas (like what I do in Python), it will just return the first matrix.
print(y, mymatrix1, mymatrix2)
#if I use the function c(), it will return a list of numbers, not three matrix.
print(c(y, mymatrix1, mymatrix2))
#if I use the function cat(), it will return a list of numbers and a value NULL(which I don't understand too), not three matrix.
print(cat(y, mymatrix1, mymatrix2))
Thanks in advance for your help and replies!