title: Estimating the missmatch rate on the rows in a matrix
body: <p>I want to estimate rates of the values distributed apart from the diagonal in a row. However, I couldn't make my function work.</p>
  
  <p>So a hypothetical data seems like:</p>
  
  <pre><code>tree = data.frame(Oak = c(10,1,3), Pine = c(2,15,1), Maple = c(1,1,20), 
  +                   row.names = c("Oak","Pine","Maple"))
  &gt; tree 
           Oak Pine Maple
    Oak     10    2     1
    Pine     1   15     1
    Maple    3    1    20
  </code></pre>
  
  <p>Let's say for Oak, I want to get the value: (2 + 1) / (10 + 2 + 1) = 0.2308 which is "taking the values where the row name and the column name aren't the same"/ "sum of the row"</p>
  
  <p>And I also want repeat this operation for all of the columns. I thought that to write down a function, especially for the big real datasets would be better.</p>
  
  <p>So I came up this function:</p>
  
  <pre><code>miss.rate = function(data) {
  rate.x = sum(data[(data["i",] != data[,"i"]),])/
  (sum(data["i",]))
  data.frame(tree = "i", rate  = rate.x)
  }
  </code></pre>
  
  <p>However, it didn't work as I expected and I don't get where it goes wrong.</p>
  
  <p>My expected output for the function was:</p>
  
  <pre><code>tree  rate
  Oak   0.2308
  Pine  0.1176
  Maple 0.1667
  </code></pre>
  
  <p>Suggestions would be great?</p>