How to wrap the reactive elements inside a progress bar(Graphic)

261 views
Skip to first unread message

harish .g

unread,
Nov 17, 2014, 8:49:19 PM11/17/14
to shiny-...@googlegroups.com
Hi,

I have .txt file and .xlsx file which will be uploaded into shiny. 
The .txt upload is fine, the builtin progress bar shows perfect progress.
But in the case of .xlsx file upload I have merging operation doing inside reactive element so it is not coinciding with the actual progress. (Progress bar always finishes ahead of the task)

I can use pbapply, but then again I have to monitor them through command line, this is not what I am looking for.

I am very much interested in making the built in progress bar in connection with the entire upload process inside the reactive element. How can I do that.

This is my program.

ui.R
shinyUI(fluidPage(
  titlePanel("Uploading Files"),
sidebarLayout(
    sidebarPanel(
      fileInput('file1', 'Choose first file to upload',
                accept = c(
                  'text/csv',
                )
      ),))sidebarLayout(
    sidebarPanel(
      fileInput('file1', 'Choose second file to upload',
                accept = c(
                 
                  '.xlsx'
                )
      ),
)))
server.R
shinyServer(function(input, output) {
a <- reactive({
   fileinput1 <- input$file1
   if (is.null(fileinput1))
   return(NULL)
   read.table(fileinput1$datapath, header = TRUE, col.names =  c("Experiment","Mesocosm","Hour","Nphy","Cphy","CHLphy","Nhet","Chet","Ndet","Cdet","DON","DOC","DIN","DIC","AT","dCCHO","TEPC","Ncocco","Ccocco","CHLcocco","PICcocco","PAR","Temperature","Salinity","CO2atm","u10","DICflux","CO2ppm","CO2mol","pH"))
   #a$Chla <- a$CHLphy + a$CHLcocco  #Add new columns as per observation data
   #a$PON <- a$Nphy + a$Nhet + a$Ndet + a$Ncocco 
 })
 
 #Upload Observation Data 
b <- reactive({
  #xlfile <- list.files(pattern = "*.xlsx")
  fileinput2 <- input$file2
      if (is.null(fileinput2))
        return(NULL)
      xlfile <- fileinput2$datapath
  wb <- loadWorkbook(xlfile)
  sheet_ct <- wb$getNumberOfSheets()
  for( i in 1:sheet_ct) {    #read the sheets into 3 separate dataframes (mydf_1, mydf_2, mydf3)
    print(i)
    variable_name <- sprintf('mydf_%s',i)
    assign(variable_name, read.xlsx(xlfile, sheetIndex=i))
  }
  colnames(mydf_1) <- names(mydf_3)
  colnames(mydf_2) <- names(mydf_3)
  full_data <- rbind(mydf_1[-1,],mydf_2[-1,],mydf_3[-1,]) #making one dataframe here
  b <- lapply(full_data,function(x) as.numeric(x))
})
})

How can I achieve this ?

Joe Cheng

unread,
Nov 18, 2014, 1:01:22 PM11/18/14
to harish .g, shiny-...@googlegroups.com
You can't affect the behavior of the file upload progress bar; it always reflects the progress of the upload itself. However, you can introduce another progress bar for the processing step.

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/shiny-discuss/c732cb4e-adaf-44f2-ba50-07ee537c35f7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages