introduction to shiny
play

Introduction to Shiny BUILDIN G W EB AP P LICATION S W ITH S H IN - PowerPoint PPT Presentation

Introduction to Shiny BUILDIN G W EB AP P LICATION S W ITH S H IN Y IN R Ramnath Vaidyanathan VP of Product Research Introduction to Shiny BUILDING WEB APPLICATIONS WITH SHINY IN R What is a web app? Updates based on user input/interaction


  1. Introduction to Shiny BUILDIN G W EB AP P LICATION S W ITH S H IN Y IN R Ramnath Vaidyanathan VP of Product Research

  2. Introduction to Shiny BUILDING WEB APPLICATIONS WITH SHINY IN R

  3. What is a web app? Updates based on user input/interaction Made up of UI & server BUILDING WEB APPLICATIONS WITH SHINY IN R

  4. What is a web app? Displays paths to the White House for different presidential candidates. BUILDING WEB APPLICATIONS WITH SHINY IN R

  5. What is a web app? DataCamp mobile app BUILDING WEB APPLICATIONS WITH SHINY IN R

  6. How does a web app work? A web app is a thing that updates based on user input/interaction BUILDING WEB APPLICATIONS WITH SHINY IN R

  7. What is Shiny? BUILDING WEB APPLICATIONS WITH SHINY IN R

  8. Why should data scientists build web apps? BUILDING WEB APPLICATIONS WITH SHINY IN R

  9. Why should data scientists build web apps? plot_kmeans( data = iris, x = 'Sepal.Length', y = 'Sepal.Width', nb_clusters = 3 ) BUILDING WEB APPLICATIONS WITH SHINY IN R

  10. Why should data scientists build web apps? library(shiny) ui <- fluidPage( h1('K-Means Clustering App'), selectInput('x', 'Select x', names(iris), 'Sepal.Length'), selectInput('y', 'Select y', names(iris), 'Sepal.Width'), numericInput('nb_clusters', 'Select number of clusers', 3), plotly::plotlyOutput('kmeans_plot') ) server <- function(input, output, session){ output$kmeans_plot <- plotly::renderPlotly({ plot_kmeans(iris, input$x, input$y, input$nb_clusters) }) } shinyApp(ui = ui, server = server) BUILDING WEB APPLICATIONS WITH SHINY IN R

  11. Why should data scientists build web apps? BUILDING WEB APPLICATIONS WITH SHINY IN R

  12. Let's practice! BUILDIN G W EB AP P LICATION S W ITH S H IN Y IN R

  13. Build a "Hello, world" Shiny app BUILDIN G W EB AP P LICATION S W ITH S H IN Y IN R Kaelen Medeiros Data Scientist

  14. Parts of a Shiny app Load shiny library(shiny) Create the UI with a HTML function ui <- fluidPage() De�ne a custom function to create the server server <- function(input, output, Run the app session) { } shinyApp(ui = ui, server = server) BUILDING WEB APPLICATIONS WITH SHINY IN R

  15. Hello, world!!! library(shiny) ui <- fluidPage( "Hello, world!!!" ) server <- function(input, output, session) { } shinyApp(ui = ui, server = server) BUILDING WEB APPLICATIONS WITH SHINY IN R

  16. Ask a question (with an input!) ui <- fluidPage( textInput("name", "Enter a name:"), textOutput("q") ) server <- function(input, output) { output$q <- renderText({ paste("Do you prefer dogs or cats,", input$name, "?") }) } BUILDING WEB APPLICATIONS WITH SHINY IN R

  17. Let's practice! BUILDIN G W EB AP P LICATION S W ITH S H IN Y IN R

  18. Build a babynames explorer Shiny app BUILDIN G W EB AP P LICATION S W ITH S H IN Y IN R Ramnath Vaidyanathan VP of Product Research

  19. Sketch your app BUILDING WEB APPLICATIONS WITH SHINY IN R

  20. Add inputs (UI) ui <- fluidPage( titlePanel("Baby Name Explorer"), textInput('name', 'Enter Name', 'David') ) server <- function(input, output, session){ } shinyApp(ui = ui, server = server) BUILDING WEB APPLICATIONS WITH SHINY IN R

  21. Add outputs (UI/server) ui <- fluidPage( titlePanel("Baby Name Explorer"), textInput('name', 'Enter Name', 'David'), plotOutput('trend') ) server <- function(input, output, session){ output$trend <- renderPlot({ ggplot() }) } shinyApp(ui = ui, server = server) BUILDING WEB APPLICATIONS WITH SHINY IN R

  22. Add outputs (UI/server) BUILDING WEB APPLICATIONS WITH SHINY IN R

  23. Update layout (UI) ui <- fluidPage( titlePanel("Baby Name Explorer"), sidebarLayout( sidebarPanel( textInput('name', 'Enter Name', 'David') ), mainPanel( plotOutput('trend') ) ) ) server <- function(input, output, session){ output$trend <- renderPlot({ggplot()}) } BUILDING WEB APPLICATIONS WITH SHINY IN R

  24. Update layout (UI) BUILDING WEB APPLICATIONS WITH SHINY IN R

  25. Update output (server) ui <- fluidPage( ... ) server <- function(input, output, session){ output$trend <- renderPlot({ data_name <- subset( babynames, name == input$name ) ggplot(data_name) + geom_line( aes(x = year, y = prop, color = sex) ) }) } BUILDING WEB APPLICATIONS WITH SHINY IN R

  26. Let's practice! BUILDIN G W EB AP P LICATION S W ITH S H IN Y IN R

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend