Extracting dataframe from list column

I'm building a shiny app which holds multiple datasets with associated metadata. To organize this I thought it would be easiest to have a tibble as the main object with a column to house the actual data (list column).

data <- tibble(
  id = c(1, 2),
  name = c("default_1", "default_2"),
  df = list(as_tibble(iris), as_tibble(Titanic)),
  description = c("The Iris Dataset", "Titanic Dataset"),
  defined_vars = list(tibble(key = character(),
                        value = character())),
  changelog = list(tibble(key = character(),
                          value = character()))
)

That looks like its supposed to however whenever I go to fetch the dataframe I want to do something like
data %>% filter(names == input$selected_dataset) %>% pull(df)
or even just base subsetting but referencing any specific df observation returns a list of 1 with the tibble in it so I have to do
data %>% filter(names == input$selected_dataset) %>% pull(df) %>% pluck(1)
which doesn't seem right. Is there any way to have a column of tibbles (as opposed to a column of one element lists that contain tibbles) or a more elegant way to extract them or a better way to approach this all together?

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.