<h1>Extending accessibility of open-source statistical software to the masses: A shiny case study</h1> <h2>Brandon LeBeau</h2> <h3>University of Iowa</h3> # 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 - Shiny is an open-source framework for creating applications viewed in a web browser with R. - Shiny Examples: + <http://shiny.rstudio.com/gallery/movie-explorer.html> + <https://gallery.shinyapps.io/drinkr/> + <http://wordbank.stanford.edu/analyses?name=item_trajectories> # 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 - Simple user interface example from RStudio - <http://shiny.rstudio.com/gallery/telephones-by-region.html> ```r 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 - The server file for RStudio example - <http://shiny.rstudio.com/gallery/telephones-by-region.html> ```r 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. + Note, the following packages are required: shiny, shinydashboard, pdfsearch, DT <https://github.com/lebebr01/pdfsearch> ```r install.packages('devtools') devtools::install_github('lebebr01/pdfsearch') pdfsearch::run_shiny() ``` # Case Study 2 - simglm + Note, need the following packages: shiny, shinydashboard, DT, simglm, ggplot2, lme4, highcharter <https://github.com/lebebr01/simglm> ```r 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? - Twitter: @blebeau11 - Website: <http://brandonlebeau.org> - Slides: <http://brandonlebeau.org/2016/10/07/canam.html> - GitHub: <http://github.com/lebebr01>