I have a two-level list similar to the one described here, created from importing CSVs.
Converting nested list to dataframe
List of 21
Toronto
Color: Blue
Code: 7600
Count: 50,000
Boston
Color: Red
Code: 800
Count: 60,000
etc.
I want to generate a matrix for a heat map from this. I used the following solution to convert the list to a data.frame and then matrix.
library(data.table)
rbindlist(mylist, fill=TRUE)
However, as it is being converted, I want to have a column that identifies the city which is a list title. Or alternatively any other solution that would allow me to generate the following.
City | Color | Code | Count
---------------------------