Loop through a R matrix row-wise and print elements -


this question has answer here:

got basic r for-loop matrix question:

my matrix looks this:

2    4    3 1    5    7 

all want print these elements row wise , not column wise. answer should 2 4 3 1 5 7. try result column wise i.e `2 1 4 5 3 7. since m beginning r wondering if can done for-loop loops column wise , not row-wise

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]) 

Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

javascript - Rivets.js rv-show not working with rv-each -