Hello,
I am trying to create a dashboard to display static PNG images when the user selects items in the sidebar. I have the images in the www folder of my working directory (C:/R) and in the shiny www folder.
I am confused exactly where the images need to be on my computer and how to specify the name (and/or location) in the renderImage command. No matter what I try, the images will not appear on the dashboard. I am using RunApp in RStudio V 1.1.456. My R version is 3.5.1.
Any help/advice would be much appreciated!
Here is the code:
library(shiny)
library(shinydashboard)
library(png)
ui <- dashboardPage(
dashboardHeader(title = "BluePlus BlueMinus"),
dashboardSidebar(
menuItem("Bottom 10 Scores", icon = icon("arrow-down"),
menuSubItem("Bottom 10 Hospitals",tabName = "b10h"),
menuSubItem("Bottom 10 States",tabName = "b10s")),
menuItem("Top 10 Scores", icon = icon("arrow-up"),
menuSubItem("Top 10 Hospitals",tabName = "t10h"),
menuSubItem("Top 10 States",tabName = "t10s")),
menuItem("Number of Cases", icon = icon("medkit"),
menuSubItem("Regional Cases",tabName = "regionalcasesmap"),
menuSubItem("State Cases",tabName = "statecasesmap")),
menuItem("Heat Map - Scores", tabName = "heat", icon = icon("map")),
menuItem("HAI Measures", tabName = "hai", icon = icon("ruler-combined")),
menuItem("SIR Scores", icon = icon("diagnoses"),
menuSubItem("County",tabName = "sircntymap"),
menuSubItem("City",tabName = "sircitymap"),
menuSubItem("State",tabName = "sirstatemap")),
menuItem("Treemaps", icon = icon("tree"),
menuSubItem("Cases",tabName = "treemapcases"),
menuSubItem("Scores",tabName = "treemapscore"))
),
dashboardBody(
tabItems(
tabItem("b10h",
fluidPage(box(title = "Bottom 10 Hospitals",
status = "primary", solidHeader = FALSE, width = "100%",
imageOutput("bot10h", height = "100%")))),
tabItem("b10s", "Bottom 10 States"),
tabItem("t10h", "Top 10 Hospitals"),
tabItem("t10s", "Top 10 States"),
tabItem("regionalcasesmap", "Regional HAI Cases"),
tabItem("statecasesmap", "State HAI Cases"),
tabItem("heat", "Heat Map - SIR Scores"),
tabItem("hai", "HAI Measures"),
tabItem("sircntymap", "SIR Scores - County Level"),
tabItem("sircitymap", "SIR Scores - City Level"),
tabItem("sirstatemap", "SIR Scores - State Level"),
tabItem("treemapcases", "Tree Map of HAI Cases"),
tabItem("treemapscore", "Tree Map of SIR Scores")
)
)
)
server <- function(input, output, session) {
output$bot10h <- renderImage({
return(list(src = "Bottom_10_Hosp.png",contentType = "image/png"))
}, deleteFile = FALSE) #where the src is wherever you have the picture
}
shinyApp(ui=ui, server=server)