I am trying to create a Shiny app with a form that generate tabs and input (e.g., textInput, selectInput, etc.) based on the inputs stored in a dataframe. I created a simple example below that explains what I am trying to accomplish. Any ideas? I would like to use tidyverse but another approach will work.
# This is what I want
tabsetPanel(
tabPanel("1",
textInput("a", "a_lab"),
textInput("b", "b_lab")),
tabPanel("2",
textInput("c", "c_lab"),
textInput("d", "d_lab")),
tabPanel("3",
textInput("e", "e_lab"),
textInput("f", "f_lab"))
)
# I have a dataframe that looks like this as my input
tab_str <- data.frame(
tabnam=c(1,1,2,2,3,3),
id=letters[1:6],
lab=paste0(letters[1:6],"_lab")
)
# My function to make input controls are something like this
make_ctrl <- function(id, lab) textInput(id, lab)
# How can I obtain what I want--example at the top--using a "loop" approach;
# if possible using tidyverse; obviously what I have below is not working
tab_str %>% map(make_ctrl, id=tab_str$id)