Description Usage Arguments Details Value Examples
Time series objects don't allow missing years or months.
Check and fill missing data with NAs w/ {tsibble}
functions and provide
output as tsibble with generated Year_Month as time index.
1 | uts_data_check_and_fill_w_na(data, key = NULL)
|
data |
A data frame with monthly "count" in long format and separate columns "Year" and "Month" |
key |
Variable(s) that uniquely determine time indices. NULL (dafault) for empty key. Required, if multiple time indices exist (e.g. key = "Measure" if Temperature and Precipitation data exist) |
Time series objects don't allow gaps in time (missing years or months). With tsibble functions check and fill gaps in time and add NA count values and provide output in wide Month format (Year Temp_Precip Jan Feb .... Dec)
data input format (Month in long format)
Year Month Temp_Precip count
<dbl> <dbl> <chr> <dbl>
1 1887 1 Temperature NA
2 1887 1 Precipitation 4
3 1887 2 Temperature NA
:
5 2019 12 Temperature 4.55
6 2019 12 Precipitation 30.4
data output format (Month in wide format)
Year Temp_Precip Jan Feb ... Dec
<dbl> <fct> <dbl> <dbl> ... <dbl>
1 1887 Temperature NA NA ... NA
:
3 1889 Temperature -3.1 -2.09 ...-1.01
data frame and tsibble, e.g.:
A tsibble: 754 x 4
Year_Month Year Month count
<mth> <dbl> <fct> <dbl>
1 2 3 4 5 6 7 8 | data <- monthly_climate_basel %>%
dplyr::select(City, Measure, Year, Month, count)
uts_data_check_and_fill_w_na(data, key = "Measure")
# delete all "2017" and "Feb" rows and fill with NAs
data <- monthly_climate_basel %>%
dplyr::filter(Year != 2017 & Month != "Feb")
uts_data_check_and_fill_w_na(data, key = "Measure")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.