Learn R Programming

amadeus (version 1.2.2)

calculate_lagged: Calculate temporally lagged covariates

Description

The calculate_lagged() function calculates daily temporal lagged covariates from the output of calculate_covariates() or calc_*().

Usage

calculate_lagged(from, date, lag, locs_id, time_id = "time", geom = FALSE)

Value

a data.frame object

Arguments

from

data.frame(1). A data.frame containing calculated covariates returned from calculate_covariates() or calc_*().

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 SpatVector? Default is FALSE. The coordinate reference system of the SpatVector is that of from. To return as a SpatVector, from must also be a SpatVector

See Also

calculate_covariates()

Examples

Run this code
## NOTE: Example is wrapped in `\dontrun{}` as function requires a large
##       amount of data which is not included in the package.
if (FALSE) {
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"
)
}

Run the code above in your browser using DataLab