Extending accessibility of open-source statistical software to the masses A shiny case study
[This article was first published on Educate-R - R, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
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
- Pros:
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:
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
- User Interface (ui.r)
- What the user sees and interacts with
- R Analysis (server.r)
- The R code running behind the scenes
User Interface
- Simple user interface example from RStudio
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
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
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
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://educate-r.org
- Slides: http://educate-r.org/2016/10/07/canam.html
- GitHub: http://github.com/lebebr01
To leave a comment for the author, please follow the link and comment on their blog: Educate-R - R.
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.