-1

I need to calculate the % change in values for Argentina for the entire column and store it in a data frame:
enter image description here

% change is 2nd value- 1st value/ 1st value *100 say if a column has
30
40
%change is 40-30/30 =33.33%

GGamba
  • 13,140
  • 3
  • 38
  • 47
TheNewbie
  • 11
  • 3

1 Answers1

1

Pls read abot how to make a reproducible example

Supposing df is your data.frame. Using dplyr:

library(dplyr)
df %>%
    mutate(change = (Argentina - lead(Argentina)) / Argentina * 100

Community
  • 1
  • 1
GGamba
  • 13,140
  • 3
  • 38
  • 47