I need to calculate the % change in values for Argentina for the entire column and store it in a data frame:
% change is 2nd value- 1st value/ 1st value *100
say if a column has
30
40
%change is 40-30/30 =33.33%
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