panel_collect {panelWranglR} | R Documentation |
Collect a panel, from wide to long
Description
Transforms cross sectional/time dummies to unified variables
Usage
panel_collect(data, cross.section = NULL, cross.section.columns = NULL,
time.variable = NULL, time.variable.columns = NULL)
Arguments
data |
The panel to transform |
cross.section |
The name of the transformed cross sectional variable supply as chracter. |
cross.section.columns |
The names of the columns indicating cross sections to collect. |
time.variable |
The name of the transformed time variable supply as character. |
time.variable.columns |
The names of the columns indicating time variables to collect. |
Details
For time variables named like "Time_Var_i" with arbitrary i, the program will check that all time variables are named using this convention, and strip this convention
Value
A collected data.table, with new columns constructed by collecting from the wide format.
Examples
x_1 <- rnorm( 10 )
cross_levels <- c( "AT", "DE" )
time <- seq(1:5)
time <- rep(time, 2)
geo_list <- list()
for(i in 1:length(cross_levels))
{
geo <- rep( cross_levels[i],
100 )
geo_list[[i]] <- geo
}
geo <- unlist(geo_list)
geo <- as.data.frame(geo)
example_data <- cbind( time,
x_1 )
example_data <- as.data.frame(example_data)
example_data <- cbind( geo,
example_data)
names(example_data) <- c("geo", "time", "x_1")
# generate dummies using panel_dummify()
test_dummies <- panel_dummify( data = example_data,
cross.section = "geo",
time.variable = "time")
panel_collect( data = test_dummies,
cross.section = "geo",
cross.section.columns = c( "AT", "DE"))
[Package panelWranglR version 1.2.13 Index]