extracting data from a deeply nested list

I was going to suggest the use of purrr::pluck(), then then reading through the doco I discovered you could actually just use a purrr::map().

You’re very close: you need to pass a list of accessors to map() rather than a character vector, and there’s an accessor you’ve missed.

nestedlist %>% map( list('data', 1, 'name') )

[[1]]
[[1]][[1]]
[1] "john"

[[1]][[2]]
[1] "litz"


[[2]]
[[2]][[1]]
[1] "frank"

[[2]][[2]]
[1] "doe"

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top