r/R_Programming • u/snicksn • Jul 25 '16
Nested list to df?
I have a list that looks like below. Problem is there is a nested list ($toLoc) inside.
[[1]]
[[1]]$timeAtLoc
[1] "2016-07-29T00:20:00"
[[1]]$id
[1] "83"
[[1]]$toLoc
[[1]]$toLoc[[1]]
[1] "LA"
[[1]]$toLoc[[2]]
[1] "NY"
[[1]]$num
[1] "3"I think I want to get it all in a (long) df looking something like:
id timeAtLoc toLoc
83 2016-07-26T00:26:00 LA
83 2016-07-26T00:26:00 NYAny advice?
Thanks
2
Upvotes
View all comments
Show parent comment
2
u/snicksn Aug 15 '16
After lots of trial and error I came up with something using lapply that was better than the loop above