Hi there,
I am creating a shiny app for the systematic review extraction part. It gets the ID of a record from database and in the app a user can fill all of the required boxes.
Now, I should have three questions with checkboxes. If user clicks one of them, there should appear other boxes (which is my problem).
it is in a for loop and I don`t know how can I add the conditional panel in the loop
Below are my codes:
redcapdb<- redcapdb[seq(dim(redcapdb)[1],1),] #also reverse because shiny builds page bottom up
for (i in 1:nrow(redcapdb)) {
insertUI(
selector = "#add",
where = "afterEnd",
ui = fluidRow(id= paste0("rcid_",redcapdb$id[i]),
column(7, br(),
HTML(paste0("REDCap ID: ",redcapdb$id[i],"")),
br(), br(),
HTML(paste0("Title:",redcapdb$title[i],",",redcapdb$authoryear[i])),
br(),br(),
HTML("<a target="_blank" href="",redcapdb$url[i],"" >Link to the full text"),
br(),br(),
#Cluster check
# HTML("<b><font size=2.5>Are there two clusters reported in this study? (please see above)<font color=\"#FF0000\"> *</font></font></b>"),
# checkboxInput(paste0('helpme', redcapdb$id[i]), 'No', value = FALSE, width = NULL),
#
HTML("<b><mark style=\"background-color:#FFFFE0\"><font size=6>General Information</font></mark></b><br><br>"),
#aim
textAreaInput(paste0("studyaim",redcapdb$id[i]),HTML("Aim/objective of the study:<font color=\"#FF0000\"> *</font>"), "",
width = 380, height = 150),
br(),
#design
selectInput(paste0("studydesign", redcapdb$id[i]), HTML("Study design:<font color=\"#FF0000\"> *</font>"),
choices = c("Case series" = 1, "Cross sectional study" = 2, "Cohort study" = 3, "Mathematical modelling study" = 4, "Case-control study" = 5, "Outbreak Investigation" = 6, "Other" = 88),
selected = FALSE,
multiple = FALSE,
selectize = FALSE, width = 380),
br(),
#oth_spec
textInput(paste0("otherstudydesign", redcapdb$id[i]),HTML("Please specify other study design:"), "", width = 380),
br(),
#gen_diag
selectInput(paste0("diagnosis", redcapdb$id[i]),HTML("SARS-CoV-2 infection diagnosed by:<font color=\"#FF0000\"> *</font>"),
choices = c("PCR" = 1, "Serology" = 2, "Both PCR and Serology" = 3),
selected = FALSE,
multiple = FALSE,
selectize = FALSE, width = 380),
br(),
#region
textInput(paste0("regions", redcapdb$id[i]), HTML("Region or comments from country:<font color=\"#FF0000\"> *</font>"), "", width = 380),
br(),
#fup
HTML("<b><font size=2.5>Duration of follow-up time (choose all that apply):<font color=\"#FF0000\"> *</font></font></b>"),
checkboxInput(paste0('ibcheck1', redcapdb$id[i]), '14 days after the last possible exposure date', value = FALSE, width = NULL),
checkboxInput(paste0('ibcheck2', redcapdb$id[i]), '7 days after diagnosis', value = FALSE, width = NULL),
checkboxInput(paste0('ibcheck3', redcapdb$id[i]), 'Until negative PCR result', value = FALSE, width = NULL),
checkboxInput(paste0('ibcheck4', redcapdb$id[i]), '>7 days after diagnosis', value = FALSE, width = NULL),
br(),
HTML("<b><font size=2.5>which questions are addressed in this study?<font color=\"#FF0000\"> *</font></font></b>"),
checkboxInput(paste0('ibcheck5', redcapdb$id[i]), 'Question 1: Amongst people who become infected with SARS-CoV-2, what proportion does not experience symptoms at all during their infection?', value = FALSE, width = NULL),
checkboxInput(paste0('ibcheck6', redcapdb$id[i]), ' <b>Question 2.1:</b> What is the secondary attack rate (SAR) from asymptomatic or pre-symptomatic index cases?<br><b>OR</b><br><b>Question 2.2:</b> What proportion of SARS-CoV-2 infections is accounted for by people who are either asymptomatic throughout infection, or pre-symptomatic?', value = FALSE, width = NULL),
br(),
textAreaInput(paste0("fccomment", redcapdb$id[i]), HTML("Comments<font color=\"#FF0000\"> *</font>"), "", width = 400, height = 150),
actionButton(paste0('c', redcapdb$id[i]), paste0("Submit:",redcapdb$id[i])),br(),
HTML("<font size=2><span style=\"font-weight:normal\">Please check all mandatory fields(<font color=\"#FF0000\">*</font>) are complete before submitting</font></span><br>"),br(),
HTML("<font size=5><strong>-----------------------------------------------------------------------------</strong><br>")
),
column(5,
HTML("<b><mark style=\"background-color:#FFFFE0\"><font size=6>Question 1</font></mark></b><br>"),
checkboxInput(paste0('question1', redcapdb$id[i]), '', value = FALSE),
#PROBLEM Is HERE
conditionalPanel(condition = "input.question1 == true",
selectInput(paste0('select1', redcapdb$id[i]),HTML("Question 1 - Was the sample invited in <i>cluster 2</i> to participate a close or true representation of the target population?<font color=\"#FF0000\"> *</font>"),
choices = c("High" = 1, "Unclear" = 2, "Low" = 3),
selected = FALSE,
multiple = FALSE,
selectize = FALSE, size = 3, width = 380)),
HTML("<b><mark style=\"background-color:#FFFFE0\"><font size=6>Question 2.1</font></mark></b><br>"),
#checkboxInput(paste0('question2', redcapdb$id[i]), '', value = FALSE, width = NULL),
HTML("<b><mark style=\"background-color:#FFFFE0\"><font size=6>Question 2.2</font></mark></b><br>")
#checkboxInput(paste0('question3', redcapdb$id[i]), '', value = FALSE, width = NULL),
)
)
)
}
problem is in input.question1