Overview
Hello, I am trying to work with displaying different plots using checkboxes within tabsetPanels. I am working with a dynamic amount number of panels, so that is the reason for creating the UI contents within the server portion.
Ideal Output
For each tabPanel:
iris plot outputs if no checkboxes are selected
mtcars plot outputs if Box One is selected
islands plot outputs if Box Two is selected
sleep plot outputs if both Box One and Box Two are selected
What I have tried
-I have tried to use condtionalPanels to try to & capture the cases. I was under the impression that the value returns 'TRUE' if checked & 'FALSE' if unchecked, however I receive NULL for each of the boxed values, even if I set the default value to be checked.
-I believe my underlying issue is my lack of ability to trigger the dynamic checkboxes for each tabPanel
Disclaimer
This is a reproducible example, the default values of originally created tabPanels is set to 5. I did not accommodate proper code if the value were to change for the sake of simplicity.
Sample Code:
ui <- navbarPage(title="Dynamic tabsetPanels",id="navbar",
tabPanel("Home",
textInput(inputId = "numPanels",
label = "Enter # of Panels to produce",
value = 5)
),tabPanel("Analysis",
tabsetPanel(id = "tabs"))
)
server <- function(input, output) {
plotOne = renderPlot({plot(iris)})
plotTwo = renderPlot({plot(mtcars)})
plotThree = renderPlot({plot(islands)})
plotFour = renderPlot({plot(sleep)})
observe({
req(input$numPanels)
lapply(1:input$numPanels,function(i){
tabName = paste("Tab",i,sep=" ")
first = paste0("first",i)
second = paste0("second",i)
appendTab(inputId = "tabs",
tab = tabPanel(
tabName,
fluidPage(
sidebarLayout(
sidebarPanel(
#side-panel code
h2("Features"),
checkboxInput(inputId=first,label="Box One"),
checkboxInput(inputId=second,label="Box Two")
),mainPanel(
#output when nothing clicked
conditionalPanel(
condition = "!glue(input.{first} && !glue(input.{second})",
plotOutput(iris)
),
#output when box one is clicked
conditionalPanel(
condition = "glue(input.{first})",
plotOutput(mtcars)
),
#output when box two is clicked
conditionalPanel(
condition = "glue(input.{second})",
plotOutput(islands)
),
#output when box one and two are clicked
conditionalPanel(
condition = "glue(input.{first}) && glue(input.{second})",
plotOutput(sleep)
)
)
)
)
)
)
})
})
}
shinyApp(ui=ui, server=server)
Any suggestions would be greatly appreciated!
First issue with your code is the use of glue to create your conditions, i.e. you have to do e.g. condition = glue("input.{first}") instead of condition = "glue(input.{first})" to evaluate the glue string. Second issue is that in the plotOutputs you have to use the names of the outputs, e.g. plotOutput("plotOne") instead of plotOutput(iris). Finally, even after fixing these issues your app will not work as desired as you can't use outputs with the same id in several places or tabs, i.e. you get a duplicated id error. To fix that you also have to create a dynamic list of outputs so that the ids are unique.
library(shiny)
library(glue)
ui <- navbarPage(
title = "Dynamic tabsetPanels", id = "navbar",
tabPanel(
"Home",
textInput(
inputId = "numPanels",
label = "Enter # of Panels to produce",
value = 5
)
), tabPanel(
"Analysis",
tabsetPanel(id = "tabs")
)
)
server <- function(input, output) {
observe({
req(input$numPanels)
lapply(1:input$numPanels, function(i) {
output[[paste0("plotOne", i)]] <- renderPlot(plot(iris))
output[[paste0("plotTwo", i)]] <- renderPlot(plot(mtcars))
output[[paste0("plotThree", i)]] <- renderPlot(plot(islands))
output[[paste0("plotFour", i)]] <- renderPlot(plot(sleep))
})
})
observe({
req(input$numPanels)
lapply(1:input$numPanels, function(i) {
tabName <- paste("Tab", i, sep = " ")
first <- paste0("first", i)
second <- paste0("second", i)
appendTab(
inputId = "tabs",
tab = tabPanel(
tabName,
fluidPage(
sidebarLayout(
sidebarPanel(
# side-panel code
h2("Features"),
checkboxInput(inputId = first, label = "Box One"),
checkboxInput(inputId = second, label = "Box Two")
), mainPanel(
# output when nothing clicked
conditionalPanel(
condition = glue("!input.{first} && !input.{second}"),
plotOutput(paste0("plotOne", i))
),
# output when box one is clicked
conditionalPanel(
condition = glue("input.{first}"),
plotOutput(paste0("plotTwo", i))
),
# output when box two is clicked
conditionalPanel(
condition = glue("input.{second}"),
plotOutput(paste0("plotThree", i))
),
# output when box one and two are clicked
conditionalPanel(
condition = glue("input.{first} && input.{second}"),
plotOutput(paste0("plotFour", i))
)
)
)
)
)
)
})
})
}
shinyApp(ui = ui, server = server)
Related
My app contains two tabSetPanel that are created based on user input (in the example below the user input is a group of radio buttons). The user input determines both the number of tabs in both tabSetPanels AND the selected tab. I also want the two tabSetPanels to display the same tab whenever user input is changed or different tab is selected in either sets. The original app contains feature that prevents me from merging the two tabSetPanels. The problem is that both tabSetPanels initially display tabs without any content.
Here is a minimal reproducible example:
library(shiny)
ui <- fluidPage(
sidebarLayout(
sidebarPanel(
# User input for number of tabs and selected tab
radioButtons("tabSelector", "Select Number of Tabs", 1:3, 1),
br()
),
mainPanel(
uiOutput(
"set1"
),
uiOutput(
"set2"
)
)
)
)
server <- function(input, output, sesstion){
output$set1 <- renderUI({
tabs <- list()
for(i in seq_len(input$tabSelector)){
tabs[[i]] <- tabPanel(
title = paste0("tab",i),
value = i,
numericInput(
paste0("num",i),
"Number",
value = 0
)
)
}
do.call(tabsetPanel, c(tabs,
list(id = "set1",
selected = input$tabSelector)))
})
output$set2 <- renderUI({
tabs <- list()
for(i in seq_len(input$tabSelector)){
tabs[[i]] <- tabPanel(
title = paste0("tab",i),
value = i,
numericInput(
paste0("num",i),
"Number",
value = 0
)
)
}
do.call(tabsetPanel, c(tabs,
list(id = "set2",
selected = input$tabSelector)))
})
# Bind the two tabSetPanels
observeEvent(input$set1, {
updateTabsetPanel(inputId = "set2", selected = input$set1)
})
observeEvent(input$set2,{
updateTabsetPanel(inputId = "set1", selected = input$set2)
})
} # end server function
if (interactive()) {
shinyApp(ui, server)
}
Thanks in advance
The value of a tabPanel must be a character string :
output$set1 <- renderUI({
tabs <- list()
for(i in seq_len(input$tabSelector)){
tabs[[i]] <- tabPanel(
title = paste0("tab",i),
value = as.character(i),
numericInput(
paste0("num",i),
"Number",
value = 0
)
)
}
do.call(tabsetPanel, c(tabs,
list(id = "set1",
selected = as.character(input$tabSelector))
))
})
In output$set2 you don't need to set the value of the selected argument, because it will be set by the updateTabsetPanel.
Duplicated ids are not allowed in HTML, so you have to change the id paste0("num",i) of your numeric inputs to something else in one of the two tabsets.
Here is a video which explains what I want.
I want to upload a file and then for each column, a checkbox should appear.
If the checkbox is checked, then a dropdown list and two textinputs should be shown for each column.
If it's not checked, then the checkbox and two textinputs should disappear.
This image has only two text inputs and a dropdown for the first column but it should have two textinput and dropdown for each checkbox.
Check out the analysis tab after uploading a data file
UI code:
shinyUI(
navbarPage(title="Analysis",
tabPanel(title="Input",
sidebarLayout(
sidebarPanel(
fileInput("file","Upload the file"),
checkboxInput('file_has_headers',"Take Column Names from the first row of the file",value= TRUE),
checkboxInput('show_head_only',"Display only first 6 rows. Uncheck this to see entire file",value= TRUE),
radioButtons(inputId = 'sep', label = 'Separator', choices = c(Comma=',',Semicolon=';',Tab='\t', Space=''), selected = ','),
textAreaInput("domains", 'Enter the comma separated list of dimensions, for example: verbal ability, numerical ability' ),
width = 4
),
mainPanel(
wellPanel(
DT::dataTableOutput("uploaded_table"
),# Displays the uploaded table by using js dataTable from DT package
),
width = 8
),
position = 'left'
)
), #End of Input Tab panel
tabPanel(title="Verification",
fluidRow(
column(2,
"V",
uiOutput('choose_columns')
),
column(2,
"Key",
textInput('anser_key',"",placeholder = 'e.g. A')
),
column(4,
"Dimension",
uiOutput("domain_dropdown",inline = FALSE)
),
column(3,
"Valid Options",
textInput('valid_options',"",placeholder = 'e.g. A,B,C,D')
),
) # End Fluid row
), #End of Verification Tab Panel
navbarMenu(title="Analayis",
tabPanel(title="Item Analysis", "content"
), #End of Item Analysis Tab Panel
tabPanel(title="Test Analysis", "content"
) #End of Test Analysis Tab Panel
) #End of navbarMenu
) #End of navbarPage
) #end of shinyUI
Server code:
library(shiny)
library(DT)
options(shiny.maxRequestSize=300*1024^2)
shinyServer(function(input, output) {
#1: Get the uploaded file in the data variable
data <- reactive({
uploaded <- input$file
#if(is.null(file1)){return("No file is selected or selected file is not in the right format. Please check the documentation and upload correct file.")}
req(uploaded) #req retruns a silence rather than error and is better than using if()
if(input$show_head_only){
head(read.csv(file=uploaded$datapath, sep=input$sep,header = input$file_has_headers)) #head() returns only first 6 rows
} else {
read.csv(file=uploaded$datapath, sep=input$sep,header = input$file_has_headers)
}
})
#2:set the elemet for domain dropdown list.
output$domain_dropdown <- renderUI({
items <- strsplit(input$domains,',')[[1]] #It creates a list and [[1]] retuns the list as c('','') which is needed for select input
selectInput(inputId = "domains", label = "", choices = items)
})
#3: set element to show the uploaded csv file as a table
output$uploaded_table<- DT::renderDataTable(
data(), # If a variable contains the output of reactive() function, it must be used as a function.
server=TRUE, #Important to keep this as true so that large datasets do not crash the browser
options = list(
scrollX = TRUE
),
) # End of uploaded table output setting
#4: Set dynamic checkboxes based on the number of columns in the data
output$choose_columns <- renderUI({
req(data())
colnames <- names(data())
checkboxGroupInput("columns", "Choose columns",
choices = colnames,
# selected = colnames
)
})
})
Perhaps you are looking for this.
ui <- shinyUI(
navbarPage(title="Analysis",
tabPanel(title="Input",
sidebarLayout(
sidebarPanel(
fileInput("file","Upload the file"),
checkboxInput('file_has_headers',"Take Column Names from the first row of the file",value= TRUE),
checkboxInput('show_head_only',"Display only first 6 rows. Uncheck this to see entire file",value= TRUE),
radioButtons(inputId = 'sep', label = 'Separator', choices = c(Comma=',',Semicolon=';',Tab='\t', Space=''), selected = ','),
textAreaInput("domains", 'Enter the comma seperated list of dimensions, for example: verbal ability, numerical ability' ),
width = 4
),
mainPanel(
wellPanel(
DT::dataTableOutput("uploaded_table"
),# Displays the uploaded table by using js dataTable from DT package
),
width = 8
),
position = 'left'
)
), #End of Input Tab panel
tabPanel(title="Verification",
fillRow(flex = c(1,4),
fillCol(uiOutput('choose_columns')),
fillCol(fluidRow(column(8,uiOutput('kdv'))))
) ## end of fillRow
), #End of Verification Tab Panel
navbarMenu(title="Analayis",
tabPanel(title="Item Analysis", "content"
), #End of Item Analysis Tab Panel
tabPanel(title="Test Analysis", "content"
) #End of Test Analysis Tab Panel
) #End of navbarMenu
) #End of navbarPage
) #end of shinyUI
library(shiny)
library(DT)
options(shiny.maxRequestSize=300*1024^2)
server <- shinyServer(function(input, output) {
#1: Get the uploaded file in the data variable
data <- reactive({
uploaded <- input$file
#if(is.null(file1)){return("No file is selected or selected file is not in the right format. Please check the documentation and upload correct file.")}
req(uploaded) #req retruns a silence rather than error and is better than using if()
if(input$show_head_only){
head(read.csv(file=uploaded$datapath, sep=input$sep,header = input$file_has_headers)) #head() returns only first 6 rows
} else {
read.csv(file=uploaded$datapath, sep=input$sep,header = input$file_has_headers)
}
})
#2:set the element for domain dropdown list.
output$domain_dropdown <- renderUI({
req(input$columns)
items <- strsplit(input$columns,',') # [[1]] #It creates a list and [[1]] returns the list as c('','') which is needed for select input
selectInput(inputId = "domains", label = "", choices = items)
})
#3: set element to show the uploaded csv file as a table
output$uploaded_table<- DT::renderDataTable(
data(), # If a variable contains the output of reactive() function, it must be used as a function.
server=TRUE, #Important to keep this as true so that large datasets do not crash the browser
options = list(
scrollX = TRUE
),
) # End of uploaded table output setting
#4: Set dynamic checkboxes based on the number of columns in the data
output$choose_columns <- renderUI({
req(data())
colnames <- names(data())
checkboxGroupInput("columns", "Choose columns",
choices = colnames,
# selected = colnames
)
})
output$kdv <- renderUI({
n <- length(names(data()))
colnames <- names(data())
if (is.null(input$columns)){return(NULL)
}else{
tagList(
lapply(1:n, function(i){
lapply(input$columns , function(par){
if (colnames[i]==par){
div(
div(style="display: inline-block; vertical-align:top; width: 145px ;",textInput(paste0('answer_key',i),"",placeholder = 'e.g. A')),
div(style="display: inline-block; vertical-align:top; width: 155px ;",selectInput(paste0('sel_var',i), "", choices=data()[[par]])),
div(style="display: inline-block; vertical-align:top; width: 145px ;",textInput(paste0('valid_options',i),"",placeholder = 'e.g. A,B,C,D'))
)
}
})
})
)
}
})
})
shinyApp(ui, server)
Probably very basic question - but can't translate similar posts I've found to my exact issue.
Within an R Shiny app, I have a first drop-down menu that is populated by a vector produced on the server - this allows me to make one set of choices.
I want to have a tick box that then introduces a second drop down - but I want that drop down to disappear if I un-tick the tick box.
I've had a go - see MWE below - the graph is just there to keep to the structure of my original code (obviously I'm aware my drop-downs do nothing but that's not the case in the original but wanted the MWE to be as 'M' as possible).
If I remove the removeUI() line then ticking the tick-box does create a new drop down as required - but then un-ticking the tick box fails to remove it.
I'm obviously missing something; any help much appreciated as I totally suck at R Shiny but really want to get better!
library(shiny)
library(shinyMobile)
# define UI elements
ui <- f7Page(
f7SingleLayout(
navbar = f7Navbar(
),
f7Card(htmlOutput("initial_drop_down"), #first drop down
f7checkBox(inputId = "switch", label = "Introduce second choice", FALSE), #tick box for second drop down if required
htmlOutput("reactive_drop_down") #second drop down
),
f7Shadow(
intensity = 16,
f7Card(
plotOutput("distPlot", height = "800px") # plot - originally linked to drop down choices but an arbitrary graph here for simplicity
)
)
)
)
# server calculations
server <- function(input, output) {
library(ggplot2)
# generate first drop down - done on server side since usually choices vector is comprised of information read in from files
output$initial_drop_down = renderUI({
selectInput(inputId = "initial_choice",
label = "First choice:",
choices = c("Choice 1", "Choice 2", "Choice 3"))
})
observeEvent(input$initial_choice, {
# trying to add second drop down based on action in switch - not convinced my use of observeEvent is quite right - issue likely sits in here.
observeEvent(input$switch, {
if(input$switch == T){
output$reactive_drop_down = renderUI({
selectInput(inputId = "second_choice",
label = "Second (dynamic) choice:",
choices = c(1,2,3))
})
}else{
removeUI(selector ="#reactive_drop_down")
}
})
output$distPlot <- renderPlot({
ggplot(data = cars) + geom_line(aes(x=speed, y=dist))
})
})
}
# Run the application
shinyApp(ui = ui, server = server)
Could you use conditionalPanel? Put your htmlOutput for your second input there in your ui. I would avoid using nested observeEvent and output.
library(shiny)
library(shinyMobile)
library(ggplot2)
# define UI elements
ui <- f7Page(
f7SingleLayout(
navbar = f7Navbar(
),
f7Card(htmlOutput("initial_drop_down"), #first drop down
f7checkBox(inputId = "switch", label = "Introduce second choice", FALSE), #tick box for second drop down if required
conditionalPanel(
condition = "input.switch==1",
htmlOutput("reactive_drop_down") #second drop down
)
),
f7Shadow(
intensity = 16,
f7Card(
plotOutput("distPlot", height = "800px") # plot - originally linked to drop down choices but an arbitrary graph here for simplicity
)
)
)
)
# server calculations
server <- function(input, output) {
# generate first drop down - done on server side since usually choices vector is comprised of information read in from files
output$initial_drop_down = renderUI({
selectInput(inputId = "initial_choice",
label = "First choice:",
choices = c("Choice 1", "Choice 2", "Choice 3"))
})
output$reactive_drop_down = renderUI({
selectInput(inputId = "second_choice",
label = "Second (dynamic) choice:",
choices = c(1,2,3))
})
output$distPlot <- renderPlot({
ggplot(data = cars) + geom_line(aes(x=speed, y=dist))
})
}
# Run the application
shinyApp(ui = ui, server = server)
I'm creating a simple Shiny UI that allow users to either input text or upload file to create a word cloud, the sidebar shows normal, but main panel continues to show
Error in [.data.frame: undefined columns selected'.
Avoid initial warning with default value set in textAreaInput
Key code as below:
ui <- fluidPage(
h1("Word Cloud"),
sidebarLayout(
sidebarPanel(
# Add radio buttons input
radioButtons(
inputId = "source",
label = "Word source",
choices = c(
"Use your own words" = "own",
"Upload a file" = "file"
)
),
conditionalPanel(
condition = "input.source == 'own'",
textAreaInput("text", "Enter text",value="Paste here",rows = 7)
),
conditionalPanel(
condition = "input.source == 'file'",
fileInput("file", "Select a txt file (encoding='UTF-8')")
),
colourInput("col", "Background color", value = "white"),
# Add a "draw" button to the app
actionButton(inputId = "draw", label = "Draw!")
),
mainPanel(
wordcloud2Output("cloud")
)
)
)
library(tidyverse)
library(jiebaR)
mixseg = worker()
server <- function(input, output) {
data_source <- reactive({
if (input$source == "own") {
(data <- as.data.frame(table(mixseg <= input$text)))
} else if (input$source == "file") {
f<-read_file(input$file$datapath)
if(is.null(f)){
return(NULL)
}else{
data <- as.data.frame(table(mixseg <=f))
}
}
return(data)
})
output$cloud <- renderWordcloud2({
input$draw
isolate(
wordcloud2(data_source(), backgroundColor =input$col))
})
}
There are multiple issues with your code.
wordcloud2 requires a data.frame including word and frequency count in two columns. Currently you are providing data_source() as input which is a reactive structure that returns a single character string.
You need to properly parse the textInput server-side, which means that you need to create a wordcloud2-suitable data.frame from the input provided through textAreaInput; in fact, using textAreaInput is probably not the best element to use here, as your input text is highly structured and textAreaInput is best used for unstructured text values, see ?textAreaInput. But let's continue with your textAreaInput for pedagogical purposes.
You should also include a check that ensures that the wordcloud only gets drawn if there is actually any data to use. We can do this using validate, see code below. Not including this check will result in a Warning: Error in [.data.frame: undefined columns selected.
Less of an issue but not helping your post in terms of clarity: You are not using input_file at all; ditto for colourInput.
Following is a minimal reproducible example (where I've removed the unnecessary parts)
library(shiny)
library(shinyjs)
library(wordcloud2)
ui <- fluidPage(
h1("Word Cloud"),
sidebarLayout(
sidebarPanel(
# Add radio buttons input
radioButtons(
inputId = "source",
label = "Word source",
choices = c(
"Use your own words" = "own",
"Upload a file" = "file")
),
conditionalPanel(
condition = "input.source == 'own'",
textAreaInput("text", "Enter comma-separated text", rows = 7)
),
conditionalPanel(
condition = "input.source == 'file'",
fileInput("file", "Select a file")
)
),
mainPanel(
wordcloud2Output("cloud")
)
)
)
server <- function(input, output) {
data_source <- reactive({
if (input$text != "")
as.data.frame(table(unlist(strsplit(input$text, "[, ]"))))
else
NULL
})
output$cloud <- renderWordcloud2({
validate(need(data_source(), "Awaiting data"))
wordcloud2(data_source(), backgroundColor = "white")
})
}
This produces e.g.
I'm building a new Shiny app and I although it works, the code is too extensive and it is not as reactive as I wanted. Right now I have at server.R
dayData <- reactive({...})
pday <- function(data){...}
output$distPlotday <- renderPlot(function() {print(pday(dayData)) })
and at ui.R
plotOutput("distPlotday")
for each variable in
checkboxGroupInput("checkGroup", "Dataset Features:",
choices = c("day","hour","source","service","relevancy","tollfree","distance","similarity"))
But I wish I could do something more fancy like this:
shinyServer(function(input, output, session) {
...
output$sliders <- renderUI({
lapply(input$checkGroup, function(i) {
fluidRow(
column(4,
selectInput(paste0('trans',i), i,
choices = c('linear','quadratic','sine')) ,
conditionalPanel(
condition = "input[[paste0('trans',i)]]== 'sine'",
withMathJax(),
h5("Put in your initial kicks for: $$a*\\sin(b*x+c)+d$$"),
textInput3(paste0('trans',i,'a'), h5('A:'),
value = 10),
textInput3(paste0('trans',i,'b'), h5('C:'),
value = 1),
textInput3(paste0('trans',i,'c'), h5('D:'),
value = 0.1),
helpText("Note: B has already been picked up")
),
plotOutput(paste0('distPlot',i))
))
})
})
...
}))
.
shinyUI(navbarPage("",
tabPanel("Data",
sidebarLayout(
sidebarPanel(
checkboxGroupInput("checkGroup", label = h5("Dataset Features:"),
choices = c("day","hour","source","service","relevancy","tollfree","distance","similarity"), inline = F,
selected = c("day","hour","source","service","relevancy","tollfree","distance","similarity"))
),
mainPanel(
numericInput("obs", label = h5("Number of observations to view"), 15, min = 10, max = 20, step = 1),
tableOutput("view")
)
)
),
tabPanel("Variable transformation", uiOutput(outputId = "sliders"))
))
Using lapply and renderUI. But
plotOutput(paste0('distPlot',i))
is not ploting anything, and the
conditionalPanel(condition = "input[[paste0('trans',i)]]== 'sine'",...)
don't show up conditionally, instead it's always there.
Any suggestions? Thanks for the help!
I wasn't sure what you wanted to do with the plotOutput call, since as far as I can tell there wasn't any example code included that linked to it. However, I managed to put together a working example for dynamically showing/hiding the selection boxes and text fields for the sine parameters.
I found it easier to implement by moving the ui generation from the server into the ui. This gets around the problem of conditions being evaluated for input that doesn't exist yet, since on the ui side the functions are just writing html.
An additional benefit is that this way the input fields don't get re-rendered every time the checkbox input changes - this means that their values persist through toggling them on and off, and that enabling or disabling a single variable won't cause the others' values to reset.
The code:
library(shiny)
vars <- c("day","hour","source","service","relevancy",
"tollfree","distance","similarity")
ui <- shinyUI(navbarPage("",
tabPanel("Data",
sidebarLayout(
sidebarPanel(
checkboxGroupInput("checkGroup", label = h5("Dataset Features:"),
choices = c("day","hour","source","service","relevancy",
"tollfree","distance","similarity"), inline = F,
selected = c("day", "hour","source","service","relevancy",
"tollfree","distance","similarity")
)
),
mainPanel(
numericInput("obs", label = h5("Number of observations to view"),
value = 15, min = 10, max = 20, step = 1),
tableOutput("view")
)
)
),
tabPanel("Variable transformation",
fluidRow(
column(4,
lapply(vars, function(i) {
div(
conditionalPanel(
condition =
# javascript expression to check that the box for
# variable i is checked in the input
paste0("input['checkGroup'].indexOf('", i,"') != -1"),
selectInput(paste0('trans',i), i,
choices = c('linear','quadratic','sine'))
),
conditionalPanel(
condition =
paste0("input['trans", i, "'] == 'sine' ",
" && input['checkGroup'].indexOf('", i,"') != -1"),
withMathJax(),
h5("Put in your initial kicks for: $$a*\\sin(b*x+c)+d$$"),
textInput(paste0('trans',i,'a'), h5('A:'), value = 10),
textInput(paste0('trans',i,'b'), h5('C:'), value = 1),
textInput(paste0('trans',i,'c'), h5('D:'), value = 0.1),
helpText("Note: B has already been picked up")
)
)
})
)
)
)
))
server <- shinyServer(function(input, output, session) {})
shinyApp(ui, server)
PS. For dynamically showing/hiding or enabling/disabling objects, the package shinyjs by Dean Attali (link) has some nice tools that allow you to call basic javascript by using only R syntax.