title: Row-wise percentage with R
body: <p>I have a dataframe which looks something like this, but for the whole year </p>
  
  <pre><code> date       v1  v2  v3  v4  v5  v6  v7  v8  Fraction   Percent
  01-02-2013  0    0   1   1   1   1   1   0   0.625
  01-03-2013  0    0   1   1   0   0   0   0   0.25
  01-04-2013  0    0   0   0   0   1   0   0   0.125
  01-05-2013  0    0   0   0   0   0   1   0   0.125
  01-06-2013  0    0   0   0   0   0   0   0   0
  ....................................................
  ....................................................
  </code></pre>
  
  <p>My interest is to calculate the percentage of the Fraction column. I tried using the <code>prop.table</code> but it didn't work. 
  I also tried </p>
  
  <pre><code>df$Percent &lt;- df$Fraction * 100
  </code></pre>
  
  <p>it gave me the following error</p>
  
  <pre><code>Error in df$Fraction[i] * 100 : non-numeric argument to binary operator
  </code></pre>
  
  <p>I have tried doing this in a loop and here is the code that i have used</p>
  
  <pre><code>df$Fraction &lt;- 'NA'
  df$Percent &lt;- 'NA'
  for (i in 1:nrow(df)) {
    df$Fraction[i] &lt;- round(sum(df[i, 2:9], na.rm=F)/8, 2)
    # I have used only one of the following at one time
    df$Percent[i] &lt;- prop.table(as.array(df$Fraction[i]), margin= 2) *100
    df$Percent[i] &lt;- df$Fraction[i] * 100
  }
  </code></pre>