Download presentation
Presentation is loading. Please wait.
Published byKory Baldwin Modified over 6 years ago
1
Dashboards – Part Two “I think, aesthetically, car design is so interesting - the dashboards, the steering wheels, and the beauty of the mechanics. I don't know how any of it works, I don't want to know, but it's inspirational.” Paloma Picasso
2
Pick Up Where We Left Today we will pick up where we left last time. More specifically, we will improve our dashboard illustrating the results (i.e., histogram) of the sentiment analysis we performed on Twitter. We will do so by adding content to our sidebar (table with text), by customizing our dashboard (color + infobox), by making it dynamic, and by adding a time series component!
3
Finally input @delta results to your dashboard (server)
library(shiny) library(shinydashboard) header <- dashboardHeader(title = on Twitter") sidebar <- dashboardSidebar() body <- dashboardBody(fluidRow( box(plotOutput("plot1", height = 250)), box( title = "Controls", sliderInput("Slider", "Number of Messages:", 1, 1500, 500)))) ui <- dashboardPage(header,sidebar,body) server <- function(input, output) { delta_scores <- score.sentiment(delta_text, pos.words, neg.words) output$plot1 <- renderPlot({ delta <- delta_scores$score[seq_len(input$Slider)] hist(delta) }) } shinyApp(ui, server)
4
Finally input @delta results to your dashboard (server)
5
Add items to your sidebar
library(shiny) library(shinydashboard) header <- dashboardHeader(title = on Twitter") sidebar <- dashboardSidebar( sidebarMenu( menuItem("Dashboard", tabName = "dashboard", icon = icon("dashboard")), menuItem("Table", tabName = "sentiment", icon = icon("table")) ) body <- dashboardBody(fluidRow( box(plotOutput("plot1", height = 250)), box( title = "Controls", sliderInput("Slider", "Number of Messages:", 1, 1500, 500)))) ui <- dashboardPage(header,sidebar,body) server <- function(input, output) { delta_scores <- score.sentiment(delta_text, pos.words, neg.words) output$plot1 <- renderPlot({ delta <- delta_scores$score[seq_len(input$Slider)] hist(delta) }) } shinyApp(ui, server)
6
Add items to your sidebar
7
Add table to your sidebar tab
library(shiny) library(shinydashboard) header <- dashboardHeader(title = on Twitter") sidebar <- dashboardSidebar(sidebarMenu( menuItem("Dashboard", tabName = "dashboard", icon = icon("dashboard")), menuItem("Table", tabName = "sentiment", icon = icon("table")) )) body <- dashboardBody(tabItems( # First tab content tabItem(tabName = "dashboard", fluidRow(box(plotOutput("plot1", height = 250)), box(title = "Controls", sliderInput("Slider", "Number of Messages:", 1, 1500, 500)))), # Second tab content tabItem(tabName = "sentiment", dataTableOutput("mytable") ))) ui <- dashboardPage(header,sidebar,body) server <- function(input, output) { delta_scores <- score.sentiment(delta_text, pos.words, neg.words) output$plot1 <- renderPlot({ delta <- delta_scores$score[seq_len(input$Slider)] hist(delta) output$mytable <- renderDataTable({delta_scores}) }) } shinyApp(ui, server)
8
Add items to your sidebar
9
Customizing dashboard
library(shiny) library(shinydashboard) header <- dashboardHeader(title = on Twitter") sidebar <- dashboardSidebar(sidebarMenu( menuItem("Dashboard", tabName = "dashboard", icon = icon("dashboard")), menuItem("Table", tabName = "sentiment", icon = icon("table")) )) body <- dashboardBody(tabItems( # First tab content tabItem(tabName = "dashboard", fluidRow(box(title = "Histogram", status = "primary", solidHeader = TRUE, collapsible = TRUE, plotOutput("plot1", height = 250)), box(title = "Controls", status = "warning", solidHeader = TRUE, collapsible = TRUE, sliderInput("Slider", "Number of Messages:", 1, 1500, 500)))), # Second tab content tabItem(tabName = "sentiment", dataTableOutput("mytable") ))) ui <- dashboardPage(skin = "green", header,sidebar,body) server <- function(input, output) { delta_scores <- score.sentiment(delta_text, pos.words, neg.words) output$plot1 <- renderPlot({ delta <- delta_scores$score[seq_len(input$Slider)] hist(delta) output$mytable <- renderDataTable({delta_scores}) }) } shinyApp(ui, server)
10
Customize dashboard
11
Make it dynamic/add infobox
library(shiny) library(shinydashboard) library(quantmod) header <- dashboardHeader(title = on Twitter") sidebar <- dashboardSidebar(sidebarMenu( menuItem("Dashboard", tabName = "dashboard", icon = icon("dashboard")), menuItem("Table", tabName = "sentiment", icon = icon("table")) , menuItem("Stock", tabName = "stock", icon = icon("dollar")) )) body <- dashboardBody(tabItems( # First tab content tabItem(tabName = "dashboard", fluidRow(box(title = "Histogram", status = "primary", solidHeader = TRUE, collapsible = TRUE, plotOutput("plot1", height = 250)), box(title = "Controls", status = "warning", solidHeader = TRUE, collapsible = TRUE, sliderInput("Slider", "Number of Messages:", 1, 1500, 500)))), # Second tab content tabItem(tabName = "sentiment", dataTableOutput("mytable")) , # Third tab content tabItem(tabName = "stock", fluidRow(infoBox(title = "Latest", icon('dollar'), getQuote('DAL')$Last, color='red'), infoBoxOutput("deltaBox")) ) )) ui <- dashboardPage(skin = "green", header,sidebar,body) server <- function(input, output) { delta_scores <- score.sentiment(delta_text, pos.words, neg.words) output$plot1 <- renderPlot({ delta <- delta_scores$score[seq_len(input$Slider)] hist(delta) output$mytable <- renderDataTable({delta_scores}) output$deltaBox <- renderInfoBox({infoBox("Website", icon('plane'), href = ' color='black')}) }) } shinyApp(ui, server)
12
Make it dynamic/add infobox
13
Add times series library(shiny) library(shinydashboard)
library(quantmod) library(dygraphs) header <- dashboardHeader(title = on Twitter") sidebar <- dashboardSidebar(sidebarMenu( menuItem("Dashboard", tabName = "dashboard", icon = icon("dashboard")), menuItem("Table", tabName = "sentiment", icon = icon("table")) , menuItem("Stock", tabName = "stock", icon = icon("dollar")) )) body <- dashboardBody(tabItems( # First tab content tabItem(tabName = "dashboard", fluidRow(box(title = "Histogram", status = "primary", solidHeader = TRUE, collapsible = TRUE, plotOutput("plot1", height = 250)), box(title = "Controls", status = "warning", solidHeader = TRUE, collapsible = TRUE, sliderInput("Slider", "Number of Messages:", 1, 1500, 500)))), # Second tab content tabItem(tabName = "sentiment", dataTableOutput("mytable")) , # Third tab content tabItem(tabName = "stock", fluidRow(infoBox(title = "Latest", icon('dollar'), getQuote('DAL')$Last, color='red'), infoBoxOutput("deltaBox"), box(title = "Closing share price", width = 12, heigth = NULL, dygraphOutput('delta') )) ) )) ui <- dashboardPage(skin = "green", header,sidebar,body) server <- function(input, output) { delta_scores <- score.sentiment(delta_text, pos.words, neg.words) output$plot1 <- renderPlot({ delta <- delta_scores$score[seq_len(input$Slider)] hist(delta) output$mytable <- renderDataTable({delta_scores}) output$deltaBox <- renderInfoBox({infoBox("Website", icon('plane'), href = ' color='black')}) output$delta <- renderDygraph({dygraph(Cl(get(getSymbols('DAL'))))})}) } shinyApp(ui, server)
14
Add times series
15
Add times series
16
Conclusion In the last two days you learned the basic structure and use of shinydashboard. It has many options, and you will need to consult the online documentation and examples to learn more about creating dashboards Just know that shinydashboard is REALLY powerful!
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.