transform.Lexis {Epi} | R Documentation |
Modify a Lexis object.
## S3 method for class 'Lexis' transform( `_data`, ...) ## S3 method for class 'Lexis' Relevel( x, states, print = TRUE, ... ) ## S3 method for class 'Lexis' levels( x ) ## S3 method for class 'Lexis' factorize( x, states, print = TRUE, ... ) ## S3 method for class 'stacked.Lexis' transform( `_data`, ...)
_data |
an object of class |
x |
an object of class |
states |
Names of the factor levels (states) for |
print |
Should a conversion between old and new levels be printed? |
... |
Additional arguments to be passed to
|
The transform method for Lexis
objects works exactly as the
method for data frames, but keeps the Lexis
attributes.
factorize
transforms the variables
lex.Cst
and lex.Xst
to factors with identical set of
levels, optionally with names given in states
, and optionally
collapsing states.
Relevel
is merely an alias for
factorize
, since the function does the same as
Relevel
, but for both the factors lex.Cst
and
lex.Xst
. A default sideeffect is to produce a table of old
states versus new states if states
is a list. Unlike
Relevel
for factors, Relevel.Lexis
does not accept a
matrix as a second argument - the number of levels of lex.Cst
is rarely (if ever) large.
If states
is NULL
, as when for example the argument is
not passed to the function, the returned object have levels of
lex.Cst
, lex.Xst
(and for stacked.Lexis
objects
lex.Tr
) shaved down to the actually occurring values.
A transformed Lexis
object.
The function levels
returns the names of the states (levels of
the factors lex.Cst
and lex.Xst
.
Martyn Plummer, Bendix Carstensen
Lexis
,
merge.Lexis
,
subset.Lexis
,
subset.stacked.Lexis
,
Relevel
data( nickel ) nic <- Lexis( data = nickel, id = id, entry = list(age=agein), exit = list(age=ageout,cal=ageout+dob,tfh=ageout-age1st), ## Lung cancer deaths are coded 2 and other deaths are coded 1 exit.status = ( (icd > 0) + (icd %in% c(162,163)) ) ) str( nic ) levels( nic ) nit <- transform( nic, cumex = exposure*(agein-age1st) ) str( nit ) ## It is still a Lexis object! summary( nic ) nix <- factorize.Lexis( nic, c("Alive","Lung","Dead")) niw <- factorize.Lexis( nix, c("Alive","Pulm","Mort")) niz <- factorize.Lexis( niw, states=list("Alive",c("Pulm","Mort")), coll=" \n& ") boxes( niw, boxpos=TRUE ) par( new=TRUE ) boxes( niz, boxpos=TRUE ) siw <- stack( niw ) str( siw )