I have a table with data over import and export from the UK during 2010-2014. I am supposed to finde the relative change in percent of import to the year before from 2011 to 2016. Currently my code looks like this:
change2010_11 <- (df$import-df$import)/df$import*100
That gives me the change in import in percent from the year before. However, I am supposed to do this for 2011 to 2016, which means I need to write a couple of lines of code.
So what I am wondering, is if I can somehow specify that I want it from 2011 to 2016 instead of writing a code for each year.
Hope someone can help.
Thanks in advance!