--
You received this message because you are subscribed to the Google Groups "Shiny - Web Framework for R" group.
To unsubscribe from this group and stop receiving emails from it, send an email to shiny-discus...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
runGist("86f6ca71c11ae3cac38d")
Hi where can I place the progressInit() in my shinyUI?I tried placing it at many places and it just wouldn't render and give me errors. This is one of my tries
shinyUI(pageWithSidebar(
headerPanel("Tabsets"),sidebarPanel(# Action buttonactionButton("goButton", "Let's go!")),# Show a tabset that includes a plot, summary, and table view# of the generated distributionmainPanel(# loadingPanel,tabsetPanel(tabPanel(title="Tab 1", plotOutput("plot1")),
progressInit(),
tabPanel(title="Tab 1", plotOutput("plot2"))))))
You don't need progressInit but withProgress/setProgress should work as before.
To view this discussion on the web visit https://groups.google.com/d/msgid/shiny-discuss/0cd1076d-2ccd-40db-b3fc-6bc896a4a157%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Below is a sample code which takes two inputs: 1) input file and 2) input number of rows. Upon clicking the "Analyze" button the output from the server command return to the "Table" in "Results" tabset. This is a simple example where the command will be executed quickly and switches to the "Results" tabsetpanel.
In real case, the command takes longer to execute. Hence, i would like to 1) show a "Status Message" or "Progress Bar" when the command is executed when "Analyze" is clicked. And then 2) switch to "Results" tabsetpanel only upon completion of the command. Any help is appreciated.
library(shiny)
library(shinydashboard)
sidebar <- dashboardSidebar(width=200,
sidebarMenu(id="tabs",
menuItem("File", tabName = "tab1",icon = icon("fas fa-file"))))
body <- tabItem(tabName = "tab1",
h2("Input File"),
fluidRow(tabPanel("Upload file", value="upload_file",
fileInput(inputId ="uploadFile",label = "Upload Input file",multiple=FALSE,
accept = c(".txt")),
checkboxInput('header', label = 'Header', TRUE)),
box(title="Filter X rows", width=7,status="info",
tabsetPanel(id="input_tab",
tabPanel("Parameters",numericInput("nrows",label="Entire number of rows",value=5, max=10),
actionButton("run","Analyze")),
tabPanel("Results", value="results",navbarPage(NULL,
tabPanel("Table",DT::dataTableOutput("res_table"),icon = icon("table"))),
downloadButton("downList", "Download"))))))
ui<- shinyUI(dashboardPage(dashboardHeader(title = "TestApp", titleWidth = 150),sidebar,dashboardBody(tabItems(body))))
server <- function(input, output, session) {
file_rows <- eventReactive(input$run, {
system(paste("cat", input$uploadFile,"|", paste0("head -",input$nrows) ,">","out.txt"),intern=TRUE)
head_rows <- read.delim("out.txt")
head_rows
})
observeEvent(input$run,{
updateTabsetPanel(session,"input_tab", "results")
})
output$res_table <- DT::renderDataTable(DT::datatable(file_rows(),options = list(searching = TRUE,pageLength = 10, rownames(NULL), scrollX = T)))
output$downList <- downloadHandler(
filename = function() {
paste0("output", ".vcf")
},
content = function(file) {
write.table(file_rows(), file, row.names = FALSE)
})
}
shinyApp(ui=ui, server=server)
I need to show the progress when actionButton 'run' is clicked, and updateTabsetPanel and renderDataTable should be done upon completion of the command in file_rows() in the server side.