pyears_tidiers {broom} | R Documentation |
These tidy the output of pyears
, a calculation of the person-years
of follow-up time contributed by a cohort of subject. Since the output of
pyears$data
is already tidy (if the data.frame = TRUE
argument
is given), this does only a little work and should rarely be necessary.
## S3 method for class 'pyears' tidy(x, ...) ## S3 method for class 'pyears' glance(x, ...)
x |
a "pyears" object |
... |
extra arguments (not used) |
tidy
returns a data.frame with the columns
pyears |
person-years of exposure |
n |
number of subjects contributing time |
event |
observed number of events |
expected |
expected number of events (present only if a
|
If the data.frame = TRUE
argument is supplied to pyears
,
this is simply the contents of x$data
.
glance
returns a one-row data frame with
total |
total number of person-years tabulated |
offtable |
total number of person-years off table |
This contains the values printed by summary.pyears
.
pyears
if (require("survival", quietly = TRUE)) { temp.yr <- tcut(mgus$dxyr, 55:92, labels=as.character(55:91)) temp.age <- tcut(mgus$age, 34:101, labels=as.character(34:100)) ptime <- ifelse(is.na(mgus$pctime), mgus$futime, mgus$pctime) pstat <- ifelse(is.na(mgus$pctime), 0, 1) pfit <- pyears(Surv(ptime/365.25, pstat) ~ temp.yr + temp.age + sex, mgus, data.frame=TRUE) head(tidy(pfit)) glance(pfit) # if data.frame argument is not given, different information is present in # output pfit2 <- pyears(Surv(ptime/365.25, pstat) ~ temp.yr + temp.age + sex, mgus) head(tidy(pfit2)) glance(pfit2) }