Description Usage Arguments Value Examples
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.
1 2 3 4 5 6 7 8 9 | slide_by_geo(
x,
slide_fun,
n = 14,
shift = 0,
col_name = "slide_value",
col_type = c("dbl", "int", "lgl", "chr", "list"),
...
)
|
x |
The |
slide_fun |
Function or formula to slide over the values in |
n |
Size of the local window (in days) to use. Default is 14. |
shift |
Number of days forward from the |
col_name |
String indicating the name of the new column that will
contain the derivative values. Default is "slide_value"; note that setting
|
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 |
A data frame given by appending a new column to x
named according
to the col_name
argument, containing the function values.
1 2 3 4 5 6 7 8 9 10 11 | ## Not run:
df <- covidcast::covidcast_signal("fb-survey", "smoothed_cli",
start_day = "2021-01-01",
end_day = "2021-01-31",
geo_type = "state")
# two equivalent ways to compute 7-day trailing averages
slide_by_geo(df, slide_fun = ~ Mean(.x$value), n = 7)
slide_by_geo(df, slide_fun = function(x, ...) Mean(x$value) , n = 7)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.