LongToWide {tvmediation} | R Documentation |
Function to transpose the data from long to wide format
Description
Transposing a dataset with repeated measurements/responses for each subject from longitudinal to wide format.
Usage
LongToWide(subject.id, time.sequence, outcome, verbose = FALSE)
Arguments
subject.id |
a column of subject identifiers |
time.sequence |
a column of time points |
outcome |
a column to be transposed |
verbose |
TRUE or FALSE (default = FALSE) prints output to screen (OPTIONAL INPUT) |
Details
If data is not sorted by subject.id, a warning message will appear. The function will then sort the data by subject.id. It is recommended that the user sorts the data prior to using this function.
Value
mat.wide |
a matrix in wide format, in which each column is the outcome for each subject and each row is the time sequence |
Examples
# CREATING A TRANSPOSED MATRIX FOR MEDIATOR `WantToSmokeLst15min`
data(smoker)
mat.wide <- LongToWide(smoker$SubjectID,
smoker$timeseq,
smoker$WantToSmokeLst15min)
[Package tvmediation version 1.1.0 Index]