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 end as 2 and other deaths as 1
exit.status = factor((icd > 0) + (icd %in% c(162,163)),
labels = c("Alive","Dead","Lung") ) )
str( nic )
levels( nic )
nit <- transform( nic, cumex = exposure * (agein - age1st) )
str( nit )
# It is still a Lexis object!
summary(nic)
# change order of levels
nix <- Relevel(nic, c("Alive", "Lung", "Dead"))
summary(nix)
# change names of levels
niw <- Relevel(nix, list("Alive" = 1, "Pulm" = "Lung", "Mort" = "Dead"))
summary(niw)
boxes(niw, boxpos = TRUE)
# combine levels
niz <- Relevel(niw, list("Alive", c("Pulm", "Mort")), coll=" \n& ")
summary(niz)
par( new = TRUE )
boxes(niz, boxpos = TRUE)
#stack Lexis object
siw <- stack(niw)
str(siw)
Run the code above in your browser using DataLab