Convert "list of lists" format to long "tidy" format

ec_lol_tidy1(data_lol, X = "X", y = "y")

Arguments

data_lol

A list of data frames containing design matrices and response vectors

X

The column name of the design matrix, default: "X"

y

The column name of the response vector, default: "y"

Value

A tidy data frame with columns for each design matrix column, the response vector, and an id column indicating which data frame the row came from

Examples

loldata<-list()
loldata[[1]]=list()
loldata[[1]]$y = c(1,2)
loldata[[1]]$X= data.frame(brand1=c(1,0, 1,0),brand2=c(0,1, 0,1),price=c(1,2))
loldata[[2]]=list()
loldata[[2]]$y = c(1,1)
loldata[[2]]$X= data.frame(brand1=c(1,0, 1,0),brand2=c(0,1, 0,1),price=c(1,2))
ec_lol_tidy1(loldata)
#> # A tibble: 8 × 7
#>   id     task   alt brand1 brand2 price     x
#>   <chr> <int> <int>  <dbl>  <dbl> <dbl> <dbl>
#> 1 1         1     1      1      0     1     1
#> 2 1         1     2      0      1     2     0
#> 3 1         2     1      1      0     1     0
#> 4 1         2     2      0      1     2     1
#> 5 2         1     1      1      0     1     1
#> 6 2         1     2      0      1     2     0
#> 7 2         2     1      1      0     1     1
#> 8 2         2     2      0      1     2     0