Learn R Programming

wlsd (version 1.0.1)

cp2long: Counting Process Format to Long format

Description

Transforms data from counting process format to the long format.

Usage

cp2long(data, id, time1, time2, status = NULL, fill = FALSE)

Value

A data frame in long format.

Arguments

data

A data frame with relevant columns.

id

A character string of the identification variable name in data.

time1

A character string of the first time point variable in data. Represents the left endpoint of the time interval.

time2

A character string of the second time point variable in data. Represents the right endpoint of the time interval.

status

A character string of the status column name in data to be treated as either an event or state.

fill

An optional argument that attempts to fill any NA values in the output for columns that might be constant within id levels.

Details

The data transition consolitdates information from the time1 and time2 argument into a single time column. All other columns are assumed to correspond to the time2 point. Thus, the first row generally consists of NA values. The fill argument will attempt to discern any constant columns within id groups in order to populate that first row.

Examples

Run this code
cp2long(data = cp_data, id = "id", time1 = "time1", time2 = "time2")

Run the code above in your browser using DataLab