title: Side-by-side pie charts of 2 matrices R
body: <p>say you have 2 matrices <code>m1</code> and <code>m2</code> and each has equal an number of columns. </p>
  
  <pre><code>m1 = matrix(0, 10, 5, dimnames = list(c("A", "B", "C", "D", "E", "F", "G", "H", "I", "J"), c(1, 2, 3, 4, 5)))
  m1[1,] = c(0,0,0,0,1)
  m1[2,] = c(0,0,0,1,1)
  m1[3,] = c(0,0,1,1,1)
  m1[4,] = c(0,0,1,1,0)
  m1[5,] = c(1,0,0,0,0)
  m1[6,] = c(1,1,1,0,0)
  m1[7,] = c(0,1,1,0,0)
  m1[8,] = c(0,1,1,0,0)
  m1[9,] = c(0,1,1,1,0)
  m1[10,] = c(1,1,1,0,1)
  
  m2 = matrix(0, 10, 5, dimnames = list(c("A", "B", "C", "D", "E", "F", "G", "H", "I", "J"), c(1, 2, 3, 4, 5)))
  m2[1,] = c(0,0,0,0,1)
  m2[2,] = c(0,0,0,1,1)
  m2[3,] = c(0,0,1,1,1)
  m2[4,] = c(0,0,1,1,0)
  m2[5,] = c(1,0,0,0,0)
  m2[6,] = c(1,1,1,0,0)
  m2[7,] = c(0,1,1,0,0)
  m2[8,] = c(0,1,1,0,0)
  m2[9,] = c(0,1,1,1,0)
  m2[10,] = c(1,1,1,0,1)
  </code></pre>
  
  <p>What I would like to see is a pie-chart comparison of these two matrices.</p>
  
  <p>One way I can think is for each column, add each row, and then use those to get fractions for a pie chart. </p>
  
  <pre><code>sumcols &lt;-function(x){
      for (i in 1:numcols(x)){
          sum &lt;- sum(x[,i])
          sums.append(sum) #python here ...
      }
      return(sums)
  }
  </code></pre>
  
  <p>so now, i can pass any matrix, get back a list of sums, which I assume now we can use to get a pie chart:</p>
  
  <pre><code>sums1 &lt;- sumcols(m1)
  sums2 &lt;- sumcols(m2)
  par(mfrow = c(1,2))
  pie(c(sums1,sums2))
  </code></pre>
  
  <p>thank you for your help!</p>