Skip to content

Instantly share code, notes, and snippets.

@ijlyttle
Last active December 14, 2020 14:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ijlyttle/6230575 to your computer and use it in GitHub Desktop.
Save ijlyttle/6230575 to your computer and use it in GitHub Desktop.
demonstration of attempt to get `conditionalPanel` to work on a file-upload condition
library(shiny)
shinyServer(function(input, output) {
# Has a file been imported?
output$csv_import_ready <- reactive({
return(!is.null(input$csv_import_file))
})
# SOLUTION (2013-08-17)
# activate the output so it runs although not displayed
# ref: https://groups.google.com/forum/#!msg/shiny-discuss/S15Vp7P72eg/yNv_O-axrd8J
outputOptions(output, "csv_import_ready", suspendWhenHidden = FALSE)
})
library(shiny)
shinyUI(pageWithSidebar(
# Application title
headerPanel("Ian's very boring app"),
sidebarPanel(
# File Import
fileInput(inputId="csv_import_file",
label="Import CSV File",
accept=c("text/csv", "text/comma-separated-values",
"text/plain")),
# Theory: Show this only when file has been imported
#
# Practice: Not shown when file has been uploaded
conditionalPanel(
condition="output.csv_import_ready",
checkboxInput(inputId="do_something", label="OK, now do something!")
)
),
mainPanel()
))
@raylandmagalhaes
Copy link

Thanks !

@starorangewww
Copy link

I have one question, if I replace checkboxGroupInput by checkboxInput in ui.R, and I want to show that choices = names(data), selected =names(data). How could I program it, thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment