LongToWide | R Documentation |
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.
LongToWide(Dataset, OutcomeIndicator, IdIndicator, TreatIndicator, OutcomeValue)
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 |
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.
Wim Van der Elst, Ariel Alonso, and Geert Molenberghs
# 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.