LongToWide {Surrogate} | R Documentation |
Reshapes a dataset from the 'long' format (i.e., multiple lines per patient) into the 'wide' format (i.e., one line per patient)
Description
Reshapes a dataset that is in the 'long' format into the 'wide' format. The dataset should contain a single surrogate endpoint and a single true endpoint value per subject.
Usage
LongToWide(Dataset, OutcomeIndicator, IdIndicator, TreatIndicator, OutcomeValue)
Arguments
Dataset |
A |
OutcomeIndicator |
The name of the variable in |
IdIndicator |
The name of the variable in |
TreatIndicator |
The name of the variable in |
OutcomeValue |
The name of the variable in |
Value
A data.frame
in the 'wide' format, i.e., a data.frame
that contains one line per subject. Each line contains a surrogate value, a true endpoint value, a treatment indicator, a patient ID, and a trial ID.
Author(s)
Wim Van der Elst, Ariel Alonso, and Geert Molenberghs
Examples
# Generate a dataset in the 'long' format that contains
# S and T values for 100 patients
Outcome <- rep(x=c(0, 1), times=100)
ID <- rep(seq(1:100), each=2)
Treat <- rep(seq(c(0,1)), each=100)
Outcomes <- as.numeric(matrix(rnorm(1*200, mean=100, sd=10),
ncol=200))
Data <- data.frame(cbind(Outcome, ID, Treat, Outcomes))
# Reshapes the Data object
LongToWide(Dataset=Data, OutcomeIndicator=Outcome, IdIndicator=ID,
TreatIndicator=Treat, OutcomeValue=Outcomes)