Description Usage Arguments Details Value
Calculate and summarize percent change in rolling average in tweetable form
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | trends_rolling_average(
x,
stat = c("cases", "mortality", "active", "testing"),
new_date = Covid19CanadaData::ccodwg_update_date(),
loc = c("all_prov", "all_hr"),
before_days = 7,
window_days = 7,
threshold = 10,
print_val = FALSE,
val_digits = 1,
change_digits = 1,
min_val_before = NULL,
min_val_new = NULL,
output_lines = NULL,
file
)
|
x |
The time series for which to calculate the rolling average. |
stat |
The stat of the time series. One of "cases", "mortality", "active", or "testing". |
new_date |
The date for which to calculate the percent change since the previous date (by default, the most recent date the dataset was updated). |
loc |
The locations for which to calculate trends. One of "all_prov" (all provinces), "all_hr" (all health regions), a vector of 2-letter province codes, or a vector of 4-number health region codes. |
before_days |
The number of days before |
window_days |
The length of the window in days for the rolling average (default = 7). |
threshold |
The percent threshold (in absolute value) for delineating a positive/negative trend from no change (default = 10). |
print_val |
Logical. Also print absolute changes in value from before date to new date? (Default = FALSE) |
val_digits |
The number of digits to print for absolute values (defaults to 1). Used if |
change_digits |
The number of digits to print for the percent change (defaults to 1). |
min_val_before |
Optional. If set, remove locations with values below the stated number on the before date (see Details). |
min_val_new |
Optional. If set, remove locations with values below the stated number on the new date (see Details). |
output_lines |
Optional. The number of lines to output (default: keep all lines). |
file |
A character string for the path and name of the output file. |
The arguments min_val_before and min_val_new can be used to censor small absolute changes that correspond to huge percent changes. For example, suppose a health region goes from 0.1 cases/day -> 0.6 cases/day represents a 500% increase but a small absolute change. Setting either min_val_before to a value > 0.1 or min_val_new to a value > 0.6 would censor this health region. Setting min_val_before to 0 implicitly censors locations with 0 to > 0 and 0 to 0, whereas setting min_val_new to 0 implicitly censors locations with percent change = -100% and 0 to 0.
A text file summarizing the trends in the selected value over a particular time range and set of locations. Includes emojis.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.