Learn R Programming

eha (version 2.11.5)

toTpch: Transform survival data to tabular form

Description

Transform a "survival data frame" to tabular form aggregating number of events and exposure time by time intervals and covariates.

Usage

toTpch(formula, data, cuts, enter = "enter", exit = "exit",
event = "event", episode = "age")

Value

A data frame with exposure time and number of events aggregated by time intervals and covariates. If all covariates are factors,this usually results in a huge reduction of the size of thedata frame, but otherwise the size of the output may be larger than the size of the input data frame

Arguments

formula

A model formula.

data

A data frame with survival data.

cuts

An ordered, non-negative vector of time points at which a hazard function changes value. Note that data are left truncated at cuts[1] (the smallest value) and right censored at c[n], where n is the length of cuts and cuts[n] == max(cuts).

enter

Character string with the name of the variable representing left truncation values.

exit

Character string with the name of the event/censoring time variable.

event

Character string with the name of the event indicator variable.

episode

Character string with the name of the output variable of the grouped time (a factor variable).

Author

Göran Broström

Details

If cuts is missing, nothing is done. Internally, this function first calls survival::survSplit and then stats::aggregate.