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 NY
Any advice?
Thanks
2
Upvotes
View all comments
Show parent comment
1
u/snicksn Aug 04 '16
Thanks, I did get crazy with lists. Its from a json, I guess thats why its gotten so unneccesarily complicated. The loop below works but I wonder if there is a terser way?