Computes the percentage change of the values in a covidcast_signal data frame. (When multiple issue dates are present, only the latest issue is considered.) See the percentage change vignette for examples.

pct_change(x, n = 14, col_name = "pct_change")

Arguments

x

The covidcast_signal data frame under consideration.

n

Size of the local window (in days) to use (bumped up to the nearest even integer, if needed). For example, if n = 10, then to compute the percentage change on November 10, we use 100 * (B - A) / A, where A is the sum of the values between November 6 and November 10, and A is the sum of the values between November 1 and November 5. Default is 14.

col_name

String indicating the name of the new column that will contain the percentage change values. Default is "pct_change"; note that we can set col_name = "value" to overwrite the existing "value" column.

Value

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