View source: R/calculate_covariates.R
calculate_lagged | R Documentation |
The calculate_lagged()
function calculates daily temporal lagged covariates
from the output of calculate_covariates()
or calc_*()
.
calculate_lagged(from, date, lag, locs_id, time_id = "time", geom = FALSE)
from |
data.frame(1). A |
date |
character(2). Start and end dates of desired lagged covariates. Length of 10 each, format YYYY-MM-DD (ex. September 1, 2023 = "2023-09-01"). |
lag |
integer(1). Number of lag days. |
locs_id |
character(1). Name of unique identifier. |
time_id |
character(1). Column containing time values. |
geom |
logical(1). Should the function return a |
a data.frame
object
In order to calculate temporally lagged covariates, from
must contain at
least the number of lag days before the desired start date. For example, if
date = c("2024-01-01", "2024-01-31)
and lag = 1
, from
must contain data
starting at 2023-12-31.
If from
contains geometry features, calculate_lagged
will return a column
with geometry features of the same name.
calculate_lagged()
assumes that all columns other than time_id
,
locs_id
, and fixed columns of "lat" and "lon", follow the genre, variable,
lag, buffer radius format adopted in calc_setcolumns()
.
calculate_covariates()
## NOTE: Example is wrapped in `\dontrun{}` as function requires a large
## amount of data which is not included in the package.
## Not run:
loc <- data.frame(id = "001", lon = -78.90, lat = 35.97)
terracliamte_covar <- calculate_terraclimate(
from = terraclimate, # derived from process_terraclimate() example
locs = loc,
locs_id = "id",
radius = 0,
fun = "mean",
geom = FALSE
)
calculate_lagged(
from = terracliamte_covar,
locs_id = "id",
date = c("2023-01-02", "2023-01-10"),
lag = 1,
time_id = "time"
)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.