Home > OS >  Percent difference between two numbers in R
Percent difference between two numbers in R

Time:06-22

DF is combined_data2015_2019 and I am trying to find the percent difference between the Economy GPD per capita. I don't need a new column I just need the percent difference. Down below is the information you'll need.

View(combined_data2015_2019)
> finland2015

$Country_2015
[1] "Finland"

$Economy_GDPperCapita_2015
[1] 1.29025

> finland2019
$Country_2019
[1] "Finland"

$Economy_GDPpercapita_2019
[1] 1.34

CodePudding user response:

This really seems more of a question about how to find a percentage difference in general, which is something you can easily google. Nonetheless, to calculate a % difference:

((original value - new value) / original value) * 100.

So,

((combined_data2015_2019$Economy_GDPperCapita_2015 - 
  combined_data_2015_2019$Economy_GDPpercapita_2019) / 
  combined_data2015_2019$Economy_GDPperCapita_2015) * 100 

((1.29025 - 1.34) / 1.29025) * 100 = ~3.85% change.

Hopefully this answers your question.

  • Related