File: Lexis_fpa.Rd

package info (click to toggle)
r-cran-popepi 0.4.13%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,656 kB
  • sloc: sh: 13; makefile: 2
file content (90 lines) | stat: -rw-r--r-- 2,456 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/utility_functions.R
\name{Lexis_fpa}
\alias{Lexis_fpa}
\title{Create a Lexis Object with Follow-up Time, Period, and Age
Time Scales}
\usage{
Lexis_fpa(
  data,
  birth = NULL,
  entry = NULL,
  exit = NULL,
  entry.status = NULL,
  exit.status = NULL,
  subset = NULL,
  ...
)
}
\arguments{
\item{data}{a \code{data.frame}; mandatory}

\item{birth}{the time of birth; A character string naming the variable in
data or an expression to evaluate - see
\link[=flexible_argument]{Flexible input}}

\item{entry}{the time at entry to follow-up; supplied the
same way as \code{birth}}

\item{exit}{the time at exit from follow-up; supplied the
same way as \code{birth}}

\item{entry.status}{passed on to \verb{[Epi::Lexis]} if not \code{NULL};
supplied the same way as \code{birth}}

\item{exit.status}{passed on to \verb{[Epi::Lexis]} if not \code{NULL};
supplied the same way as \code{birth}}

\item{subset}{a logical condition to subset by before passing data
and arguments to \verb{[Epi::Lexis]}}

\item{...}{additional optional arguments passed on to
\verb{[Epi::Lexis]}}
}
\value{
A \code{Lexis} object with the usual columns that \code{Lexis} objects
have, with time scale columns \code{fot}, \code{per}, and \code{age}.
They are calculated as

\code{fot = entry - entry} (to ensure correct format, e.g. difftime)

\code{per = entry}

and

\code{age = entry - birth}
}
\description{
This is a simple wrapper around \verb{[Epi::Lexis]} for creating
a \code{Lexis} object with the time scales \code{fot}, \code{per},
and \code{age}.
}
\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")
}