Learn R Programming

LMest (version 3.1.2)

long2wide: From data in the long format to data in the wide format

Description

Function that transforms data in the long format to data in the wide format.

Usage

long2wide(data, nameid, namet, colx, coly, aggr = T, full = 999)

Value

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

Arguments

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

Author

Francesco Bartolucci, Silvia Pandolfi, University of Perugia (IT), http://www.stat.unipg.it/bartolucci

Examples

Run this code
# 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)

Run the code above in your browser using DataLab