0

When I upload a file greater than 5MB in my Shiny application with a gVis table, the program crashes "Fatal R error". When I take the gVis table out, my program runs fine. I am also using options(shiny.maxRequestSize=-1) to bypass the normal 5MB limit in shiny.

follow up on: How to change 'Maximum upload size exceeded' restriction in Shiny and save user file inputs?

ui.R

dataset <- list('Upload a file'=c(1))

shinyUI(pageWithSidebar(

  sidebarPanel(

    fileInput('file', 'Data file'),
    radioButtons('format', 'Format', c('CSV', 'TSV')),



      conditionalPanel(condition = "input.tsp == 'sort'",
                       checkboxInput(inputId = "pageable", label = "Make table pageable"),
                       conditionalPanel("input.pageable==true",
                                        numericInput(inputId = "pagesize",
                                                     label = "Entries per page",10))              


      ),
      conditionalPanel(condition = "input.tsp == 'multi' ",


          selectInput('x', 'X', names(dataset)),
          selectInput('y', 'Y', names(dataset),  multiple=T),
          selectInput('color', 'Color', c('None', names(dataset))),

          checkboxInput('jitter', 'Jitter'),
          checkboxInput('smooth', 'Smooth'),

          selectInput('facet_row', 'Facet Row', c(None='.', names(dataset))),
          selectInput('facet_col', 'Facet Column', c(None='.', names(dataset)))

      )

  ),

  mainPanel( 
      tabsetPanel(
        tabPanel("Sortable Table", htmlOutput("gvisTable"),value="sort"),
        tabPanel("Multiplot", plotOutput('plotMulti'), value="multi"),
        id="tsp"            #id of tab
      )

  )
))

server.R

library(reshape2)
library(googleVis)
library(ggplot2)

options(shiny.maxRequestSize=-1)

shinyServer(function(input, output, session) {

  #-----------------------------------------------------------
  # Dataview Tab Inputs
  #-----------------------------------------------------------  

  data <- reactive({

    if (is.null(input$file))
      return(NULL)
    else if (identical(input$format, 'CSV'))
      return(read.csv(input$file$datapath))
    else
      return(read.delim(input$file$datapath))
  })

  observe({
    df <- data()
    str(names(df))
    if (!is.null(df)) {
      updateSelectInput(session, 'x', choices = names(df))
      updateSelectInput(session, 'y', choices = names(df))
      updateSelectInput(session, 'color', choices = c('None', names(df)))
      updateSelectInput(session, 'facet_row', choices = c(None='.', names(df)))
      updateSelectInput(session, 'facet_col', choices = c(None='.', names(df)))

    }
  })


  myOptions <- reactive({
    list(

      page=ifelse(input$pageable==TRUE,'enable','disable'),
      pageSize=input$pagesize,
      width=1000

      )
  })

  output$gvisTable <- renderGvis( {
    if (is.null(data()))
      return(NULL)

    gvisTable(data(), options=myOptions())


  })

  #-----------------------------------------------------------
  # Graphs
  #-----------------------------------------------------------  


  output$plotMulti <- renderPlot({
    if (is.null(data()))
      return(NULL)

    temp <- input$x
    p <- ggplot(data(), aes_string(x=temp, y=input$y), environment = environment()) 
    p <- p + geom_bar()

    if (input$smooth)
      p <- p + geom_smooth()

    if (input$color != 'None')
      p <- p + aes_string(color=input$color)

    facets <- paste(input$facet_row, '~', input$facet_col)
    if (facets != '. ~ .')
      p <- p + facet_grid(facets)

    if (input$jitter)
      p <- p + geom_jitter()


    multiplot(p, p)


  })


})
Community
  • 1
  • 1
user2522217
  • 345
  • 1
  • 7
  • 20
  • To answer this I would think one would need to test with code .... and I wonder if this may be a follow-on Q to an earlier question which you should have cited if that were the case. – IRTFM Aug 09 '13 at 00:07
  • It;'s also possible that you didn't search: http://stackoverflow.com/questions/18037737/how-to-change-maximum-upload-size-exceeded-restriction-in-shiny-and-save-user/18037912#18037912 – IRTFM Aug 09 '13 at 00:09
  • This is indeed a follow up, I will put my test code in edit. – user2522217 Aug 09 '13 at 00:11
  • `shiny` is a new (albeit exciting) package so I would think that "fatal errors" might better be handled in the forum that is maintained for support. (I'm not a user, and I suppose it's possible that the RStudio people have deputized SO for that functions but I'm guessing not.) – IRTFM Aug 09 '13 at 00:14

0 Answers0