I have a deeply nested list that I want to transform into a single tibble. At the top level there is some number of secondary lists. Each of these is the same length. Inside each of these is a tertiary list. Each of these contains a single value and an identifier.
What I want to do is make a tibble where the columns are named by the tertiary list identifiers, and the single values from each tertiary list are populated into that column as observations.
I have tried a lot of tweaks on something similar to this, but I'm just not that adept with these functions yet, and I'm not sure how to get this to work.
# Convert to tibble
temp <- map_dfr(lstTemp, ~tibble::tibble(!!pluck(., "identifiers") := pluck(., "values")))
Here's some code to generate a list structure like what I have.
set.seed(123) # Setting seed for reproducibility
# Create a nested list structure
nested_list <- replicate(5, {
lapply(1:14, function(counter) {
list(
identifiers = letters[counter],
values = runif(1, 1, 10)
)
})
}, simplify = FALSE)
You could accomplish the same using the following: