Description Usage Arguments Details Value Examples
View source: R/collect_panel.R
Transforms cross sectional/time dummies to unified variables
1 2 |
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. |
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
A collected data.table, with new columns constructed by collecting from the wide format.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | 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"))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.