Loop through a R matrix row-wise and print elements [duplicate]

m <- matrix(c(2, 4, 3, 1, 5, 7), 2, 3, byrow=T)
as.vector(m)

or

c(m[1, 1:3], m[2, 1:3])

Leave a Comment