• python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Facebook Twitter Instagram
Devs Fixed
  • python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Devs Fixed
Home ยป Resolved: Subtract the values from one matrix by row for each column of another matrix

Resolved: Subtract the values from one matrix by row for each column of another matrix

0
By Isaac Tonny on 17/06/2022 Issue
Share
Facebook Twitter LinkedIn

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!

matrix r
Share. Facebook Twitter LinkedIn

Related Posts

Resolved: Getting ‘502 Bad Gateway’ while deploying Springboot app in EKS

24/03/2023

Resolved: Why is NGINX’s $request_uri empty?

24/03/2023

Resolved: How to convert Java bytecode to Webassembly using CheerpJ compiler

24/03/2023

Leave A Reply

© 2023 DEVSFIX.COM

Type above and press Enter to search. Press Esc to cancel.