Slides a given function over the values in a covidcast_signal data frame, grouped by geo_value. (When multiple issue dates are present, only the latest issue is considered.) See the getting started guide for examples.

slide_by_geo(
  x,
  slide_fun,
  n = 14,
  col_name = "slide_value",
  col_type = c("dbl", "int", "lgl", "chr", "list"),
  ...
)

Arguments

x

The covidcast_signal data frame under consideration.

slide_fun

Function or formula to slide over the values in x, grouped by geo_value. To "slide" means to apply the function or formula over a trailing window of n days of data. If a function, slide_fun must take x, a data frame the same column names as the original data frame; followed by any number of named additional arguments; and ending with ..., to capture general additional arguments. If a formula, slide_fun can operate directly on .x$value, .x$time_value, etc., as in ~ mean(.x$value) to compute a trailing mean over the last n days of data.

n

Size of the local window (in days) to use. For example, if n = 5, then to estimate the derivative on November 5, we train the given method on data in between November 1 and November 5. Default is 14.

col_name

String indicating the name of the new column that will contain the derivative values. Default is "slide_value"; note that setting col_name = "value" will overwrite the existing "value" column.

col_type

One of "dbl", "int", "lgl", "chr", or "list", indicating the data type (as tibble abbreviation) for the new column. Default is "dbl".

...

Additional arguments to pass to the function or formula specified via slide_fun.

Value

A data frame given by appending a new column to x named according to the col_name argument, containing the function values.