title: Combine 2 2d matrices in one 2d matrix R
body: <p>I have 2 two-dimensional matrices which I try to combine into 1. There are 3 common sets in each matrix, voyages barges and category's. I have an binary matrix which assigns barges to voyages, and I have a matrix which states the capacity of different categorys of cargo per barge. Now what I try to create is a table which gives the capacity per voyage based on which barge is assigned to it. I made some example data, my real data is tables and data frames in R;</p>
  <p><a href="https://i.stack.imgur.com/yU44n.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/yU44n.png" alt="enter image description here" /></a></p>
  <p>table 1: capacity of category c for barge b</p>
  <p><a href="https://i.stack.imgur.com/0QLE3.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0QLE3.png" alt="enter image description here" /></a></p>
  <p>table 2: = 1 if barge b goes on voyage v</p>
  <p>Now based on these 2 tables I want to get a table, which gives me the cap of each voyage, as follows;</p>
  <p><a href="https://i.stack.imgur.com/Ki1ax.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Ki1ax.png" alt="enter image description here" /></a></p>
  <p>table 3: output table</p>
  <p>table 1 and 2 are both of type matrix in R</p>
  <p>After I work the data I import it in python, so if someone knows how to do it there instead of in R, that would work fine as well.</p>
  <p>Regards</p>