March 26, 2017

Updated Shiny app

A short post to alert the world that my modest Shiny application, showing Major League Baseball run scoring trends since 1901, has been updated to include the 2016 season. The application can be found here:
https://monkmanmh.shinyapps.io/MLBrunscoring_shiny/.

In addition to the underlying data, the update removed some of the processing that was happening inside the application, and put it into the pre-processing stage. This processing needs to happen only the once, and is not related to the reactivity of the application. This will improve the speed of the application; in addition to reducing the processing, it also shrinks the size of the data table loaded into the application.

The third set of changes were a consequence of the updates to the Shiny and ggplot2 packages in the two years that have passed since I built the app. In Shiny, there was a deprecation for "format" in the sliderInput widget. And in ggplot2, it was a change in the quotes around the "method" specification in stat_smooth(). A little thing that took a few minutes to debug! Next up will be some formatting changes, and a different approach to one of the visualizations.

 -30-

3 comments:

  1. Hello

    In your "team plot" tab (where selectInput is created server side), you have an error message that appears for a second or so, complaining about "incorrect length (0)". It is an error that I also have in my apps and that I have been able to suppress with:

    if (is.null(input$Name_of_selectInput_server_side)) {
    NULL
    } else {
    plot script
    }

    Hope this is helpful.

    Cheers
    Charles

    ReplyDelete
  2. Nice little Shiny app!

    As Charles says, this temporary error state can be suppressed. A better solution than using is.null() would be to wrap the required input with the req() function which was introduced into shiny specifically to address this issue.

    You can see https://shiny.rstudio.com/articles/req.html for more info.

    ReplyDelete
  3. Thanks to both Charles and Unknown -- I have used the req() function and the temporary error no longer appears. A simple and elegant solution.

    ReplyDelete

Note: Only a member of this blog may post a comment.