Learn R Programming

intccr (version 1.0.0)

dataprep: Data manipulation

Description

The function dataprep reshapes data from a long format to a ready-to-use format to be used directly in the function ciregic.

Usage

dataprep(data, ID, time, event, Z)

Arguments

data

data frame

ID

individuals' ID.

time

time points

event

a vector of event indicator. If observation is righ-censored, event = 0; otherwise, event = 1 or 2, where 1 represents the first cause of failure, and 2 represents the second cause of failure. The current version of package only allows for two causes of failure.

Z

a vector of variables' name

Value

a data frame

Details

The function dataprep provides a ready-to-use data format that can be directly used in the function ciregic. The returned data frame consists of id, v, u, c, and covariates as columns. The v and u indicate time window with the last observation time before the event and the first observation after the event. The c represents a type of event, for example, c = 1 for the first cause of failure, c = 2 for the second cause of failure, and c = 0 for the right-censored. Individuals who have only one time record with right-censored event will be omitted because its time interval is (0, Inf), and the lower bound v will be replaced by zero, for example (0, v], if individuals are not right-censored and have only one time record.

Examples

Run this code
# NOT RUN {
library(intccr)
dataprep(data = longdat, ID = "id", time = "t", event = "c", Z = c("z1", "z2"))

# }

Run the code above in your browser using DataLab