Function Usecases

Utility functions

Task
  • Write a function rmse that calculates the Root Mean Squared Error.
  • Test the function with the dataset below.

x = c(2,5,3,4)
y = c(2,6,5,5)

Semi-Automatic analysis workflow

dwd = read.csv("https://opendata.dwd.de/climate_environment/CDC/regional_averages_DE/seasonal/air_temperature_mean/regional_averages_tm_summer.txt", sep = ";", skip = 1)
knitr::kable(head(dwd))
Jahr summer Brandenburg.Berlin Brandenburg Baden.Wuerttemberg Bayern Hessen Mecklenburg.Vorpommern Niedersachsen Niedersachsen.Hamburg.Bremen Nordrhein.Westfalen Rheinland.Pfalz Schleswig.Holstein Saarland Sachsen Sachsen.Anhalt Thueringen.Sachsen.Anhalt Thueringen Deutschland X
1881 summer 17.13 17.11 17.03 16.39 16.62 16.12 16.24 16.24 16.66 16.90 15.80 17.19 16.20 16.88 16.46 15.95 16.53 NA
1882 summer 16.45 16.44 14.85 14.46 15.02 16.19 15.71 15.72 15.48 15.16 16.10 15.33 15.05 16.02 15.41 14.64 15.33 NA
1883 summer 17.52 17.51 15.87 15.50 16.15 16.66 16.35 16.36 16.37 16.23 16.31 16.42 16.49 17.14 16.57 15.84 16.26 NA
1884 summer 17.00 16.98 16.08 15.35 16.01 16.32 16.20 16.21 16.45 16.52 16.19 16.83 15.92 16.57 16.02 15.33 16.10 NA
1885 summer 17.18 17.17 16.63 16.05 15.84 16.06 15.78 15.78 16.11 16.28 15.53 16.65 16.29 16.63 16.10 15.43 16.18 NA
1886 summer 17.16 17.15 16.04 15.47 15.88 16.05 15.89 15.89 16.17 16.17 15.52 16.42 16.09 16.61 16.05 15.35 16.00 NA
Task
  • Write a function that calculates the long-term average temperature for a particular region in Germany.
  • The function should have three arguments: the region, the start year and the end year.
  • The function should return the temperature average between these two year for the specified region.