Shiny is –
A web application framework for R Turn your analyses into interactive web applications No HTML, CSS, or JavaScript knowledge required.
Best place to learn is the tutorial from official site.
shiny package for R
1 2 3 |
install.pacakges("shiny") |
Build a app with separate ui.R and server.R files
1 2 3 4 5 |
~/shinyapp |-- ui.R |-- server.R |
ui.R file:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
ui.R ------------ library(shiny) # Define UI for miles per gallon application shinyUI(pageWithSidebar( # Application title headerPanel("Miles Per Gallon"), sidebarPanel(), mainPanel() )) |
server.R
1 2 3 4 5 6 7 8 9 10 |
server.R ---------------- library(shiny) # Define server logic required to plot various variables against mpg shinyServer(function(input, output) { }) |
run the app
1 2 3 4 |
> library(shiny) > runApp("~/shinyapp") |
Or, with one file
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
server <- function(input, output) { output$distPlot <- renderPlot({ hist(rnorm(input$obs), col = 'darkgray', border = 'white') }) } ui <- fluidPage( sidebarLayout( sidebarPanel( sliderInput("obs", "Number of observations:", min = 10, max = 500, value = 100) ), mainPanel(plotOutput("distPlot")) ) ) shinyApp(ui = ui, server = server) |
Shiny themes -bootstrap themes
Other notes
- Tutorials http://rstudio.github.io/shiny/tutorial/#deployment-local and new site
-
Run from gist
1234shiny::runGist('3239667')shiny::runGist('https://gist.github.com/cryoguy/92a4affeead17563df15d55b630a214d')
One of the my apps
Following is one of the appz I wrote to analyze some of my research data.
Shiny Server Installation – build your own server
1 2 3 4 5 6 |
sudo pacman -S shiny-server-git #search examples R -e ".libPaths()" --quiet sudo cp -R ~/MY-APP /srv/shiny-server/ |
browse to http://<hostname>:3838/APP_NAME/ Note: Disconnected from the server error. Reasons unknown yet, reconnect several time went away usually.
Run from command line
1 2 3 |
R -e "shiny::runApp('~/shinyapp')" |
26
MAY
MAY
About the Author:
Beyond 8 hours - Computer, Sports, Family...