Learn R Programming

broom (version 0.4.3)

pyears_tidiers: Tidy person-year summaries

Description

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.

Usage

# S3 method for pyears
tidy(x, ...)

# S3 method for pyears glance(x, ...)

Arguments

x

a "pyears" object

...

extra arguments (not used)

Value

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 ratetable term is present)

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.

See Also

pyears

Examples

Run this code
# NOT RUN {
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)
}

# }

Run the code above in your browser using DataLab