A=matrix(0,4,2)
A[1,1]=2
A[1,2]=3
A[2,1]=2
A[2,2]=3
A[3,1]=2
A[3,2]=3
A[4,1]=2
A[4,2]=3
Now I want to pick up row 2,4 and return this is odd
before the first element of the row.
But I don't know how to make a loop to pick up row 2,4
A=matrix(0,4,2)
A[1,1]=2
A[1,2]=3
A[2,1]=2
A[2,2]=3
A[3,1]=2
A[3,2]=3
A[4,1]=2
A[4,2]=3
Now I want to pick up row 2,4 and return this is odd
before the first element of the row.
But I don't know how to make a loop to pick up row 2,4
If I understand your question correctly, you want to display some text and the first element of all odd rows. You can try this:
No need for a loop there. Should you want to work with a larger matrix, and take all odd rows, you can use
seq(2, nrow(A), by=2)
instead ofc(2,4)
.