In R Convert list of lists into data frame based on multiple citeria -
if create list using code
metrics<-list(m1=1,m2=2,m3=3) region_mertic <- list("west"=metrics,"east"=metrics) country_metric <- list("us"=region_mertic,"uk"=region_mertic) country <- list("country"=country_metric)
the hierarchy of list looks this:
> names(country) [1] "country" > names(country[[1]]) [1] "us" "uk" > names(country[[1]][[1]]) [1] "west" "east" > names(country[[1]][[1]][[1]]) [1] "m1" "m2" "m3"
how can convert following data frame. in essence filter countries, region "east" , metrics "m2","m3" , values.
us east m2 2 east m3 2 uk east m2 3 uk east m3 3
this should scalable big lists containing many lists of lists.
Comments
Post a Comment