tempo_wrangle: Format covariates for tempo

Description Usage Arguments Details

View source: R/tempo_wrangle.R

Description

Function for formatting a long form covariate data frame into a suitable format stuiable for tempo.

Usage

1
tempo_wrangle(x, y, vars, n_time_steps = NULL)

Arguments

x

data.frame; Long form covariate data containing covariate info for every observation/sample unit at every time step. Must contain a column, time_step, containing an integer representation of the time step (e.g. year, DOY, month, minute, etc.) for each covariate observation. Must also contain a column obs_id to relate covariates correctly to the observations in y.

y

data.frame; The observation data containing a column called obs_id with unique observation IDs for each observation (row).

vars

vector; a character vector with the column names of the covariates to be extracted and formatted from x

n_time_steps

The number of time steps you want to include in the model. This argument is useful if you have covariate data for every day of the year (365 time steps), but the event can only occur in the first n days of the year. In this case, you would specify n_time_steps as n. If NULL, Defaults to the total number of time steps available in x, length(unique(x$time_step)).

Details

The function extracts specified covariates (vars) from a long format data frame (x) for a dataset (y) for use in tempo. Returns a list of covariate matrices. Rows are named using the y$obs_id, columns are named using the time steps in x$time_step, and list elements are named for the covariates using the vars argument.


vlandau/tempo documentation built on March 18, 2020, 12:04 a.m.