I have the unemployment levels of Austria between 2006 and 2012. I would like to subtract the unemployment of each year with the year 2008 as a first step. Second i would like also to subtract the unemployment of each year with the average of the first three years combined (2006, 2007, 2008). Is there an elegant way and a short way to do it?
Here is my data:
structure(list(cntry = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L
), .Label = "Austria", class = "factor"), unemp = c(5.2, 4.9,
4.1, 5.3, 4.8, 4.6, 4.9), year = 2006:2012), row.names = c(NA,
-7L), groups = structure(list(cntry = structure(1L, .Label = "Austria", class = "factor"),
.rows = structure(list(1:7), ptype = integer(0), class = c("vctrs_list_of",
"vctrs_vctr", "list"))), row.names = 1L, class = c("tbl_df",
"tbl", "data.frame"), .drop = TRUE), class = c("grouped_df",
"tbl_df", "tbl", "data.frame"))
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…