addcensoredrows {IrregLong} | R Documentation |
Add rows corresponding to censoring times to a longitudinal dataset
Description
Add rows corresponding to censoring times to a longitudinal dataset
Usage
addcensoredrows(data, maxfu, tinvarcols, id, time, event)
Arguments
data |
The dataset to which rows are to be added. The data should have one row per observation |
maxfu |
The maximum follow-up time per subject. If all subjects have the same follow-up time, this can be supplied as a single number. Otherwise, maxfu should be a dataframe with the first column specifying subject identifiers and the second giving the follow-up time for each subject. |
tinvarcols |
A vector of column numbers corresponding to variables in data that are time-invariant. |
id |
character string indicating which column of the data identifies subjects |
time |
character string indicating which column of the data contains the time at which the visit occurred |
event |
character string indicating which column of the data indicates whether or not a visit occurred. If every row corresponds to a visit, then this column will consist entirely of ones |
Value
The original dataset with extra rows corresponding to censoring times
Examples
x <- c(1:3,1:2,1:5)
x0 <- c(rep(2,3),rep(0,2),rep(1,5))
id <- c(rep(1,3),rep(2,2),rep(3,5))
time <- c(0,4,6,2,3,1,3,5,6,7)
event <- c(1,1,1,0,1,0,1,1,1,1)
data <- as.data.frame(cbind(x,id,time,event,x0))
addcensoredrows(data,maxfu=8,id="id",time="time",tinvarcols=5,event="event")
x <- c(1:3,1:2,1:5)
x0 <- c(rep(2,3),rep(0,2),rep(1,5))
id <- c(rep(1,3),rep(2,2),rep(3,5))
time <- c(0,4,6,2,3,1,3,5,6,7)
event <- c(1,1,1,0,1,0,1,1,1,1)
data <- as.data.frame(cbind(x,id,time,event,x0))
maxfu.id <- 1:3
maxfu.time <- c(6,5,8)
maxfu <- cbind(maxfu.id,maxfu.time)
maxfu <- as.data.frame(maxfu)
addcensoredrows(data,maxfu=maxfu,id="id",time="time",tinvarcols=5,event="event")