Skip to contents

gg_miss_span is a replacement function to imputeTS::plotNA.distributionBar(tsNH4, breaksize = 100), which shows the number of missings in a given span, or breaksize. A default minimal theme is used, which can be customised as normal for ggplot.

Usage

gg_miss_span(data, var, span_every, facet)

Arguments

data

data.frame

var

a bare unquoted variable name from data.

span_every

integer describing the length of the span to be explored

facet

(optional) a single bare variable name, if you want to create a faceted plot.

Value

ggplot2 showing the number of missings in a span (window, or breaksize)

Examples


miss_var_span(pedestrian, hourly_counts, span_every = 3000)
#> # A tibble: 13 × 6
#>    span_counter n_miss n_complete prop_miss prop_complete n_in_span
#>           <int>  <int>      <int>     <dbl>         <dbl>     <int>
#>  1            1      0       3000  0                1          3000
#>  2            2      0       3000  0                1          3000
#>  3            3      1       2999  0.000333         1.00       3000
#>  4            4    121       2879  0.0403           0.960      3000
#>  5            5    503       2497  0.168            0.832      3000
#>  6            6    555       2445  0.185            0.815      3000
#>  7            7    190       2810  0.0633           0.937      3000
#>  8            8      0       3000  0                1          3000
#>  9            9      1       2999  0.000333         1.00       3000
#> 10           10      0       3000  0                1          3000
#> 11           11      0       3000  0                1          3000
#> 12           12    745       2255  0.248            0.752      3000
#> 13           13    432       1268  0.254            0.746      1700
if (FALSE) {
library(ggplot2)
gg_miss_span(pedestrian, hourly_counts, span_every = 3000)
gg_miss_span(pedestrian, hourly_counts, span_every = 3000, facet = sensor_name)
# works with the rest of ggplot
gg_miss_span(pedestrian, hourly_counts, span_every = 3000) + labs(x = "custom")
gg_miss_span(pedestrian, hourly_counts, span_every = 3000) + theme_dark()
}