Loop through a R matrix row-wise and print elements -
this question has answer here:
- how combine rows single row? [closed] 2 answers
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
Post a Comment