Hi,
I have been working on a simple dashboard of a correlation plot with data table.
First, I would like to change the colors of the plot but my codes aren’t working.
Second, the correlation plot should be separate from the data table (two menu items) but my codes resulted to two menus bearing both the plot and data table.
I hope you could again guide me and would highly appreciate if you have further suggestions in my codes for this simple dashboard.
Thank you very much and Happy Holidays.
Respectfully,
Echo
pacman:: p_load(
rio,
here,
janitor,
lubridate,
tidyverse,
ISOweek,
ggplot2,
data.table,
naniar,
hrbrthemes,
zoo,
grid
)
#Dataset
icu <- import(here("data", "hcu10Dec2023.xlsx")) %>% #use final icu data from stata then export as excel
filter(Regname=="TOTAL") %>%
select(IcuO, Date, total_covid_cases, total_severe_critical) %>%
group_by(Date, total_covid_cases, total_severe_critical) %>%
summarise(n = sum(IcuO)) %>%
rename(IcuO = n) %>%
rename("COVID-19 Cases" = total_covid_cases) %>%
rename("Severe and Critical Cases" = total_severe_critical)
library(shiny)
library(shinydashboard)
ui <-
dashboardPage(skin = "red",
dashboardHeader(title = "ICU dashboard"),
dashboardSidebar(
sidebarMenu(
menuItem("ICU", tabName = "icu", icon = icon("bed")),
menuItem("ICU table", tabName = "icu2", icon = icon("table"))
))
,
dashboardBody(
tabItems(
tabItem("icu",
box(plotOutput("correlation_plot"),
width = 8, colors = c("blue", "red")),
box(
selectInput("parameters", "Parameters:",
c("COVID-19 Cases", "Severe and Critical Cases")),
width = 4
),
tabItem("icu2",
fluidPage(
dataTableOutput("icutable")
))
))))
server <- function(input, output){
output$correlation_plot <- renderPlot({
plot(icu$IcuO, icu[[input$parameters]],
xlab = "No.of icu beds occupied", ylab = "Number")
})
output$icutable <- renderDataTable(icu)
}
shinyApp(ui, server)