title: Calculating Percentages in R Dataframe based on Total?
body: <p>I currently have a dataframe which looks like this </p>
  
  <p>EDIT NEW UPDATE OF NEW DATAFRAME </p>
  
  <pre><code>    Country    Information  Value 
      UK         Cars         50 
      UK         Sheep        20
      UK         Cats         15
      UK         Dogs         10 
      UK         Shoes        3
      UK         Hats         2
      Total                   100
  </code></pre>
  
  <p>Country column is the same repeated 6 times and last row is called Total, Information is just random info and Value are numeric, they do sum to 100 and are in Descending order from highest to lowest</p>
  
  <p>I would like to find a way within R to add a new column (df$Percentage) which calculates the percentage of each row based as a percentage of the Total in the column Value </p>
  
  <p>so for example the new column would have </p>
  
  <pre><code>Country    Information  Value     Percentage 
      UK         Cars         50     0.50 (or can be 50%)
      UK         Sheep        20     0.20 
      UK         Cats         15     0.15
      UK         Dogs         10     0.10
      UK         Shoes        3      0.03
      UK         Hats         2      0.02
      Total                   100    1.00 (or nothing here)
  </code></pre>
  
  <p>and so on to reach the end of the dataframe where TOTAL would either be blank (assuming percentage has stopped upto there or would equal 1) </p>
  
  <p>I am fairly new to R so any help is appreciated </p>
  
  <p>Thank you </p>