Extending accessibility of open-source statistical software to the masses: A shiny case study

Brandon LeBeau

University of Iowa

R

  • R is an open source statistical programming language.
    • Pros:
      • Common statistical procedures are found in R
      • Can extend functionality with packages/functions
    • Cons:
      • Need to be comfortable with code

Flexibility of R

  • R is powerful and flexible due to the many user written packages.
  • However, to capture this flexibility:
    • users need to be comfortable with programming
    • users need to find the package
    • users need to understand package specific syntax

R package documentation and examples

https://www.rdocumentation.org/packages/dplyr/versions/0.5.0/topics/summarise

Blog posts

https://blog.rstudio.org/2014/01/17/introducing-dplyr/

Vignettes

https://cran.rstudio.com/web/packages/dplyr/vignettes/introduction.html

Weaknesses of these types of documentations

  • They still rely on user understanding and reading R code.
  • Not interactive, although the user can copy and paste code into an R session.
  • This type of documentation will not capture the nontraditional useR.
  • Shiny is the path to the nontraditional useR.

What is Shiny

Advantages of Shiny

  • User needs no R knowledge
  • App is viewed in the browser so able to use
    • Javascript
    • HTML
    • CSS
  • Multiple hosting options
  • Flexible Output

Disadvantages of Shiny

  • Need a R developer to create the app.
    • More difficult as the code is somewhat different compared to traditional R code.
    • Shiny uses reactive programming.

Components of Shiny

  1. User Interface (ui.r)
    • What the user sees and interacts with
  2. R Analysis (server.r)
    • The R code running behind the scenes

User Interface

shinyUI(
  fluidPage(    
    titlePanel("Telephones by region"),
    sidebarLayout(      
      sidebarPanel(
        selectInput("region", "Region:", 
                    choices = colnames(WorldPhones)),
        hr(),
        helpText("Data from AT&T (1961) The World's Telephones.")
      ),

      mainPanel(
        plotOutput("phonePlot")  
      )
    )
  )
)

Server File

shinyServer(function(input, output) {

  output$phonePlot <- renderPlot({

    barplot(WorldPhones[ , input$region] * 1000, 
            main = input$region,
            ylab = "Number of Telephones",
            xlab = "Year")
  })
})

Case Study

  • pdfsearch
    • Note, you may need rtools to install this package.
  • This following commands will run the pdfsearch shiny application locally.
install.packages('devtools')
devtools::install_github('lebebr01/pdfsearch')
pdfsearch::run_shiny()

Case Study 2

devtools::install_github('lebebr01/simglm')
simglm::run_shiny()

Conclusions

  • Shiny can give useRs an interactive framework to try out an R package.
  • Benefits include
    • interactivity
    • no errors (for well developed Shiny applications)
    • no need to learn R or package specific syntax
    • only need a browser, no need to have R install locally when hosted on a server.

Questions?