I have a list (lgtdata3
) with 300+ elements and each list looks like the following:
lgtdat3[[1]]
$y
[1] 3 3 3
$X
1 0 1.178470 7.643059 0.5680831
0 1 1.220708 10.272480 0.7268355
0 0 0.000000 0.000000 0.0000000
$id
123
and i want to stack the y, x, and id component in each sublist of the total list into a dataframe. My ideal result would be the following:
y:
3 3 3 4 6 ...
x:
1 0 1.178470 7.643059 0.5680831
0 1 1.220708 10.27248 0.7268355
0 0 0.000120 0.000000 0.0000000
1 1 1.175660 7.6435459 0.5685431
0 1 1.228708 10.272480 0.7265355
0 0 0.001400 0.0156000 0.0055000
....
id
123 124 ...
I have tried the following methods but none of them is working:
mnl = Reduce(merge,lgtdata3)
mnl = lapply(lgtdata3, function (x) '[',(c('y', 'X','hhid')))