How do I plot the image on my shiny app. I tried to adjust my output$Graph
, but unfortunately I couldn't. Can you help me?
Thank you very much!
library(shiny)
library(shinythemes)
function.cl<-function(df,date){
df <- structure(
list(Update = c("2021-08-21","2021-08-21","2021-08-21","2021-08-21","2021-08-21"),
date = c("2021-04-01","2021-05-02","2021-06-03","2021-07-04","2021-08-05"),
D1 = c(3,1,4,5,6), DR01 = c(2,4,5,6,7), DR02 = c(6,3,2,6,1),DR03 = c(5,2,8,9,7),
DR04 = c(3,5,3,3,7)),class = "data.frame", row.names = c(NA, -5L))
historic<-subset(df,df$date<df$Update)
average<-mean(historic$D1)
standard<-sd(historic$D1)
evol<-subset(df,df$date<df$Update)
median_ocup<-sapply(evol[startsWith(names(evol), "DR")], median)
Plot1<-plot(median_ocup[1:10],xlab="Days",ylab="Number",ylim=c(1, 6))
abline(h=c(average-standard, average, average+standard), col="red", lwd=5)
return(list(
"Plot1" = Plot1
))
}
ui <- fluidPage(
ui <- shiny::navbarPage(theme = shinytheme("flatly"), collapsible = TRUE,
br(),
tabPanel("",
sidebarLayout(
sidebarPanel(
plotOutput("Graph")
br(),
),
mainPanel(
))
)))
server <- function(input, output,session) {
data <- reactive(function.cl())
output$Graph <- renderPlot({
function.cl([[1]])
Plot1<-plot(median_ocup[1:10],xlab="Days",ylab="Number",ylim=c(1, 6))
abline(h=c(average-standard, average, average+standard), col="red", lwd=5)
})
}
shinyApp(ui = ui, server = server)