Skip to contents
tvl_salaries_monthly <- tv::get_salaries(years = 2008:2021)
#> Getting 'monthly' salary table for 'tv-l' ('west') for year 2008 ... ok. (0.76s) 
#> Getting 'monthly' salary table for 'tv-l' ('west') for year 2009 ... ok. (0.70s) 
#> Getting 'monthly' salary table for 'tv-l' ('west') for year 2010 ... ok. (0.68s) 
#> Getting 'monthly' salary table for 'tv-l' ('west') for year 2011 ... ok. (0.68s) 
#> Getting 'monthly' salary table for 'tv-l' ('west') for year 2012 ... ok. (0.77s) 
#> Getting 'monthly' salary table for 'tv-l' ('west') for year 2013 ... ok. (0.66s) 
#> Getting 'monthly' salary table for 'tv-l' ('west') for year 2014 ... ok. (0.75s) 
#> Getting 'monthly' salary table for 'tv-l' ('west') for year 2015 ... ok. (0.69s) 
#> Getting 'monthly' salary table for 'tv-l' ('west') for year 2016 ... ok. (0.67s) 
#> Getting 'monthly' salary table for 'tv-l' ('west') for year 2017 ... ok. (0.68s) 
#> Getting 'monthly' salary table for 'tv-l' ('west') for year 2018 ... ok. (0.70s) 
#> Getting 'monthly' salary table for 'tv-l' ('west') for year 2019 ... ok. (0.73s) 
#> Getting 'monthly' salary table for 'tv-l' ('west') for year 2020 ... ok. (0.69s) 
#> Getting 'monthly' salary table for 'tv-l' ('west') for year 2021 ... ok. (0.73s)
DT::datatable(tvl_salaries_monthly)

Download yearly extra payments (bonus)

# Load the pipe operator
`%>%` <- magrittr::`%>%`

# Get yearly salary and bonus for each row in tvl_salaries_monthly (test 3 only)
salary_bonus <- tv::get_yearly_salary_and_bonus(
  data = tvl_salaries_monthly[1:3, ]
)
#> [1] "https://oeffentlicher-dienst.info/c/t/rechner/tv-l/west/2008?id=tv-l-2008&g=E_1&s=1"
#> [1] "https://oeffentlicher-dienst.info/c/t/rechner/tv-l/west/2008?id=tv-l-2008&g=E_1&s=2"
#> [1] "https://oeffentlicher-dienst.info/c/t/rechner/tv-l/west/2008?id=tv-l-2008&g=E_1&s=3"

# Save salary_bonus in rds file
#kwb.utils::createDirectory("./inst/extdata")
#saveRDS(salary_bonus, "./inst/extdata/yearly-salary-and-bonus.rds")
#salary_bonus <- readRDS("./inst/extdata/yearly-salary-and-bonus.rds")
  
salary_bonus$percentage <- round(
  salary_bonus$extra_yearly / salary_bonus$salary_yearly * 100, 
  digits = 2L
)

DT::datatable(salary_bonus)
bonus_summary <- salary_bonus %>%
  dplyr::group_by(union_rate, area, pay_group) %>%
  dplyr::summarise(
    min_percentage = min(percentage, na.rm = TRUE),
    max_percentage = max(percentage, na.rm = TRUE), 
    .groups = "drop"
  )

DT::datatable(bonus_summary)