## Question:

I have a 800×250 matrix`m1`

and another 800×1 matrix `m2`

. I need to subtract the values of the `m2`

by row for each column of `m1`

in R. How can I do this? The number of columns is too big to go one by one.## Answer:

You could use`m1 - c(m2)`

. The `c()`

reduces a 1-column matrix to a vector. When it is subtracted from a matrix, it will recycle to the same dimention of that matrix.If you have better answer, please add a comment about this, thank you!