#' Access price correction data from Statistics Denmark
#'
#' @title price_correction
#'
#' @author Sebastian Barfort (\email{sebastianbarfort@@gmail.com})
#' @name price_correction
#'
#' @param df Input data frame
#' @param year_variable String. What is the year identifier called in your data set?
#'
#' @seealso \url{https://github.com/sebastianbarfort/taxdk}
#' @examples
#' df = access_tax_data()
#' price_correction(df)
#'
#' @export
price_correction = function(df, year_variable = "indkomstår"){
require("dkstat")
require("lubridate")
aar.min = df %>% select_(year_variable) %>% min
aar.max = df %>% select_(year_variable) %>% max
price.correct = dst_get_data(table = "PRIS61",
HOVED = "Årsgennemsnit",TID = aar.min:aar.max, lang = "da")
price.correct = price.correct %>%
mutate(indkomstår = year(TID)) %>%
mutate(pris.korrektion = value) %>%
select(indkomstår, pris.korrektion)
df = df %>% left_join(price.correct)
return(df)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.