pull all elements with specific name from a nested list

后端 未结 4 1915
谎友^
谎友^ 2021-01-16 13:38

I have some archived Slack data that I am trying to get some of key message properties. I\'d done this by stupidly flattening the entire list, getting a data.frame or tibble

4条回答
  •  甜味超标
    2021-01-16 14:19

    Related to those provided by @Duck & @Abdessabour Mtk yesterday, purrr has a function map_depth() that will let you get a named attribute if you know its name and how deep it is in the hierarchy. REALLY useful when crawling this big nested lists, and is a simpler solution to the nested map() calls above.

    purrr::map_depth(l, 2, "type")
    

提交回复
热议问题