# NOT RUN {
# Simulate long data set for two subjects
id <- as.numeric(c(1, 1, 1, 2, 2, 2))
time <- as.numeric(c(0, 1, 2, 0, 1, 2))
a <- as.numeric(c(0, 1, 1, 1, 1, 0))
l <- as.numeric(rbinom(6, 1, 0.5))
m <- as.numeric(rbinom(6, 1, 0.5))
n <- as.numeric(rbinom(6, 1, 0.5))
mydata.long <- data.frame(id, time, a, l, m, n)
# Run the widen() function
mydata.wide <- widen(input=mydata.long,
id="id", time="time",
exposure="a",
covariate=c("l","m","n")
)
# }
Run the code above in your browser using DataLab