Lexis_fpa: Create a Lexis Object with Follow-up Time, Period, and Age...

View source: R/utility_functions.R

Lexis_fpaR Documentation

Create a Lexis Object with Follow-up Time, Period, and Age Time Scales

Description

This is a simple wrapper around Lexis for creating a Lexis object with the time scales fot, per, and age.

Usage

Lexis_fpa(
  data,
  birth = NULL,
  entry = NULL,
  exit = NULL,
  entry.status = NULL,
  exit.status = NULL,
  subset = NULL,
  ...
)

Arguments

data

a data.frame; mandatory

birth

the time of birth; A character string naming the variable in data or an expression to evaluate - see Flexible input

entry

the time at entry to follow-up; supplied the same way as birth

exit

the time at exit from follow-up; supplied the same way as birth

entry.status

passed on to Lexis if not NULL; supplied the same way as birth

exit.status

passed on to Lexis if not NULL; supplied the same way as birth

subset

a logical condition to subset by before passing data and arguments to Lexis

...

additional optional arguments passed on to Lexis

Value

A Lexis object with the usual columns that Lexis objects have, with time scale columns fot, per, and age. They are calculated as

fot = entry - entry (to ensure correct format, e.g. difftime)

per = entry

and

age = entry - birth

Examples


data("sire", package = "popEpi")

lex <- Lexis_fpa(sire, 
                 birth = "bi_date", 
                 entry = dg_date, 
                 exit = ex_date + 1L,
                 exit.status = "status")

## some special cases
myVar <- "bi_date"
l <- list(myVar = "bi_date")
sire$l <- sire$myVar <- 1

## conflict: myVar taken from data when "bi_date" was intended
lex <- Lexis_fpa(sire, 
                 birth = myVar, 
                 entry = dg_date, 
                 exit = ex_date + 1L,
                 exit.status = "status")

## no conflict with names in data
lex <- Lexis_fpa(sire, 
                 birth = l$myVar, 
                 entry = dg_date, 
                 exit = ex_date + 1L,
                 exit.status = "status")

popEpi documentation built on Aug. 23, 2023, 5:08 p.m.