title: Sum values in matrix with if statement
body: <p>I have the hourly values of the generator that works (1) or does not work (0) in the whole year. Now I need to calculate the produced electricity if I know that the generation capacity in one hour is 40GW. So sum all the hours when the generator is on and subtract the hours when is of and multiply the result with 40. I just don't know if there is any function in R to do this fast.</p>
  
  <pre><code>ccmix
    [,1] [,2]
  [1,] 1272.819    1
  [2,] 1289.226    0
  [3,] 5308.784    1
  [4,] 5338.036    0
  [5,] 5797.671    1
  [6,] 5859.749    0
  [7,] 8760.000    1
  </code></pre>