To summarise the missing values in a time series object it can be useful to calculate the number of missing values in a given time period. miss_var_span takes a data.frame object, a variable, and a span_every argument and returns a dataframe containing the number of missing values within each span.

miss_var_span(data, var, span_every)

Arguments

data

data.frame

var

bare unquoted variable name of interest.

span_every

integer describing the length of the span to be explored

Value

dataframe with variables n_miss, n_complete, prop_miss, and prop_complete, which describe the number, or proportion of missing or complete values within that given time span.

See also

Examples

miss_var_span(data = pedestrian, var = hourly_counts, span_every = 168)
#> # A tibble: 225 x 5 #> span_counter n_miss n_complete prop_miss prop_complete #> <int> <int> <dbl> <dbl> <dbl> #> 1 1 0 168 0 1 #> 2 2 0 168 0 1 #> 3 3 0 168 0 1 #> 4 4 0 168 0 1 #> 5 5 0 168 0 1 #> 6 6 0 168 0 1 #> 7 7 0 168 0 1 #> 8 8 0 168 0 1 #> 9 9 0 168 0 1 #> 10 10 0 168 0 1 #> # ... with 215 more rows
library(dplyr) pedestrian %>% group_by(month) %>% miss_var_span(var = hourly_counts, span_every = 168)
#> # A tibble: 230 x 6 #> month span_counter n_miss n_complete prop_miss prop_complete #> <ord> <int> <int> <dbl> <dbl> <dbl> #> 1 January 1 0 168 0 1 #> 2 January 2 0 168 0 1 #> 3 January 3 0 168 0 1 #> 4 January 4 0 168 0 1 #> 5 January 5 0 168 0 1 #> 6 January 6 0 168 0 1 #> 7 January 7 0 168 0 1 #> 8 January 8 0 168 0 1 #> 9 January 9 0 168 0 1 #> 10 January 10 0 168 0 1 #> # ... with 220 more rows