get_lag {gauseR} | R Documentation |
Get timelag
Description
Calculates time-lagged observations for variable x, separated by treatment.
Usage
get_lag(x, time, tau = 1, treatment = NULL, mindt = 0, maxdt = Inf)
Arguments
x |
The time series from which time lagged observations are desired (e.g. population sizes) |
time |
The time steps corresponding to each observation |
tau |
Number of time steps to use between lagged components - defaults to 1 |
treatment |
An optional vector of treatment conditions - time lags will only be computed separately within treatments - defaults to NULL (i.e. no treatments) |
mindt |
Minimum dt allowed between observations - defaults to 0 |
maxdt |
Maximum dt allowed between observations - defaults to Inf |
Value
Returns a data.frame with 7 columns: x (unlagged time series data); laggedx (lagged time series data); xmid (average of time series and lagged time series values); dt (time lag between x and laggedx); time (time for observation x); laggedtime (time for observation laggedx); treatment (treatment for observation)
Examples
data(gause_1934_science_f02_03)
lagged_data <- get_lag(x=gause_1934_science_f02_03$Volume_Species1,
time = gause_1934_science_f02_03$Day,
treatment = gause_1934_science_f02_03$Treatment)