long2wide | R Documentation |
Function that transforms data in the long format to data in the wide format.
long2wide(data, nameid, namet, colx, coly, aggr = T, full = 999)
data |
matrix of data |
nameid |
name of the id column |
namet |
name of the t column |
colx |
vector of the names of the columns of the covariates |
coly |
vector of the names of the columns of the responses |
aggr |
if wide aggregated format is required |
full |
number to use for missing data |
listid |
list of id for every unit |
listt |
list of the time occasions |
data_wide |
data in wide format |
XX |
array of the covariates |
YY |
array of the responses |
freq |
vector of the corresponding frequencies |
Francesco Bartolucci, Silvia Pandolfi, University of Perugia (IT), http://www.stat.unipg.it/bartolucci
# Example based on criminal data
# load criminal data
data(data_criminal_sim)
# consider only the first 1000 records to shorten time
out <- long2wide(data_criminal_sim[1:1000,], "id", "time", "sex",
c("y1","y2","y3","y4","y5","y6","y7","y8","y9","y10"), aggr = TRUE, full = 999)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.