Constructs lag-lead window data set from raw inputs or from data objects with suitable information stored in attributes, e.g., objects created by as_ped.

get_laglead(x, ...)

# S3 method for default
get_laglead(x, tz, ll_fun, ...)

# S3 method for data.frame
get_laglead(x, ...)

Arguments

x

Either a numeric vector of follow-up cut points or a suitable object.

...

Further arguments passed to methods.

tz

A vector of exposure times

ll_fun

Function that specifies how the lag-lead matrix should be constructed. First argument is the follow up time second argument is the time of exposure.

Examples

get_laglead(0:10, tz=-5:5, ll_fun=function(t, tz) { t >= tz + 2 & t <= tz + 2 + 3})
#> # A tibble: 121 × 3
#>        t    tz    LL
#>    <int> <int> <int>
#>  1     0    -5     0
#>  2     0    -4     0
#>  3     0    -3     0
#>  4     0    -2     0
#>  5     0    -1     0
#>  6     0     0     0
#>  7     0     1     0
#>  8     0     2     0
#>  9     0     3     0
#> 10     0     4     0
#> # ℹ 111 more rows
gg_laglead(0:10, tz=-5:5, ll_fun=function(t, tz) { t >= tz + 2 & t <= tz + 2 + 3})