├── README.md ├── app.R ├── blank_dashboard.png ├── recommendation.csv ├── revenue-dash-screenshot.PNG ├── revenue-dash-screenshot2.PNG └── slide_7.jpg /README.md: -------------------------------------------------------------------------------- 1 | # Simple (Web App) Dashboard Shiny 2 | Code and Plots used in the related article 3 | 4 | Screenshot #1: 5 | 6 | ![Revenue Dashboard Screenshot](revenue-dash-screenshot.PNG) 7 | 8 | ### Running the app 9 | 10 | * Install the required packages `install.packages(c('shiny','shinydashboard','ggplot2','dplyr'))` 11 | * Run `shiny::runGitHub("amrrs/sample_revenue_dashboard_shiny")` 12 | -------------------------------------------------------------------------------- /app.R: -------------------------------------------------------------------------------- 1 | # load the required packages 2 | library(shiny) 3 | require(shinydashboard) 4 | library(ggplot2) 5 | library(dplyr) 6 | 7 | recommendation <- read.csv('recommendation.csv',stringsAsFactors = F,header=T) 8 | 9 | #head(recommendation) 10 | 11 | 12 | #Dashboard header carrying the title of the dashboard 13 | header <- dashboardHeader(title = "Basic Dashboard") 14 | 15 | #Sidebar content of the dashboard 16 | sidebar <- dashboardSidebar( 17 | sidebarMenu( 18 | menuItem("Dashboard", tabName = "dashboard", icon = icon("dashboard")), 19 | menuItem("Visit-us", icon = icon("send",lib='glyphicon'), 20 | href = "https://www.salesforce.com") 21 | ) 22 | ) 23 | 24 | 25 | frow1 <- fluidRow( 26 | valueBoxOutput("value1") 27 | ,valueBoxOutput("value2") 28 | ,valueBoxOutput("value3") 29 | ) 30 | 31 | frow2 <- fluidRow( 32 | 33 | box( 34 | title = "Revenue per Account" 35 | ,status = "primary" 36 | ,solidHeader = TRUE 37 | ,collapsible = TRUE 38 | ,plotOutput("revenuebyPrd", height = "300px") 39 | ) 40 | 41 | ,box( 42 | title = "Revenue per Product" 43 | ,status = "primary" 44 | ,solidHeader = TRUE 45 | ,collapsible = TRUE 46 | ,plotOutput("revenuebyRegion", height = "300px") 47 | ) 48 | 49 | ) 50 | 51 | 52 | 53 | # combine the two fluid rows to make the body 54 | body <- dashboardBody(frow1, frow2) 55 | 56 | #completing the ui part with dashboardPage 57 | ui <- dashboardPage(title = 'This is my Page title', header, sidebar, body, skin='red') 58 | 59 | # create the server functions for the dashboard 60 | server <- function(input, output) { 61 | 62 | #some data manipulation to derive the values of KPI boxes 63 | total.revenue <- sum(recommendation$Revenue) 64 | sales.account <- recommendation %>% group_by(Account) %>% summarise(value = sum(Revenue)) %>% filter(value==max(value)) 65 | prof.prod <- recommendation %>% group_by(Product) %>% summarise(value = sum(Revenue)) %>% filter(value==max(value)) 66 | 67 | 68 | #creating the valueBoxOutput content 69 | output$value1 <- renderValueBox({ 70 | valueBox( 71 | formatC(sales.account$value, format="d", big.mark=',') 72 | ,paste('Top Account:',sales.account$Account) 73 | ,icon = icon("stats",lib='glyphicon') 74 | ,color = "purple") 75 | 76 | 77 | }) 78 | 79 | 80 | 81 | output$value2 <- renderValueBox({ 82 | 83 | valueBox( 84 | formatC(total.revenue, format="d", big.mark=',') 85 | ,'Total Expected Revenue' 86 | ,icon = icon("gbp",lib='glyphicon') 87 | ,color = "green") 88 | 89 | }) 90 | 91 | 92 | 93 | output$value3 <- renderValueBox({ 94 | 95 | valueBox( 96 | formatC(prof.prod$value, format="d", big.mark=',') 97 | ,paste('Top Product:',prof.prod$Product) 98 | ,icon = icon("menu-hamburger",lib='glyphicon') 99 | ,color = "yellow") 100 | 101 | }) 102 | 103 | #creating the plotOutput content 104 | 105 | output$revenuebyPrd <- renderPlot({ 106 | ggplot(data = recommendation, 107 | aes(x=Product, y=Revenue, fill=factor(Region))) + 108 | geom_bar(position = "dodge", stat = "identity") + ylab("Revenue (in Euros)") + 109 | xlab("Product") + theme(legend.position="bottom" 110 | ,plot.title = element_text(size=15, face="bold")) + 111 | ggtitle("Revenue by Product") + labs(fill = "Region") 112 | }) 113 | 114 | 115 | output$revenuebyRegion <- renderPlot({ 116 | ggplot(data = recommendation, 117 | aes(x=Account, y=Revenue, fill=factor(Region))) + 118 | geom_bar(position = "dodge", stat = "identity") + ylab("Revenue (in Euros)") + 119 | xlab("Account") + theme(legend.position="bottom" 120 | ,plot.title = element_text(size=15, face="bold")) + 121 | ggtitle("Revenue by Region") + labs(fill = "Region") 122 | }) 123 | 124 | 125 | 126 | } 127 | 128 | 129 | shinyApp(ui, server) -------------------------------------------------------------------------------- /blank_dashboard.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amrrs/sample_revenue_dashboard_shiny/2f75a0977c5c2fc5059561e4f64849c9ff788e22/blank_dashboard.png -------------------------------------------------------------------------------- /recommendation.csv: -------------------------------------------------------------------------------- 1 | Account,Product,Region,Revenue 2 | Axis Bank,FBB,North,2000 3 | HSBC,FBB,South,30000 4 | SBI,FBB,East,1000 5 | ICICI,FBB,West,1000 6 | Bandhan Bank,FBB,West,200 7 | Axis Bank,SIMO,North,200 8 | HSBC,SIMO,South,300 9 | SBI,SIMO,East,100 10 | ICICI,SIMO,West,100 11 | Bandhan Bank,SIMO,West,200 12 | -------------------------------------------------------------------------------- /revenue-dash-screenshot.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amrrs/sample_revenue_dashboard_shiny/2f75a0977c5c2fc5059561e4f64849c9ff788e22/revenue-dash-screenshot.PNG -------------------------------------------------------------------------------- /revenue-dash-screenshot2.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amrrs/sample_revenue_dashboard_shiny/2f75a0977c5c2fc5059561e4f64849c9ff788e22/revenue-dash-screenshot2.PNG -------------------------------------------------------------------------------- /slide_7.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amrrs/sample_revenue_dashboard_shiny/2f75a0977c5c2fc5059561e4f64849c9ff788e22/slide_7.jpg --------------------------------------------------------------------------------