Hello
I work on a shiny application and all work well but I have an error on the construction of my tables with input $ select
the error is
Warning: Error in $<-.data.frame: replacement has 1 row, data has 0
if (interactive()) {
ui <- dashboardPage(
dashboardHeader(
),
dashboardSidebar(
selectInput("use", label = "SELECT :",
choices = c("bureau","unité")),
selectInput("inSelect", " cHOISIR ",
choices = NULL),
sidebarMenuOutput("menu")
),
dashboardBody(
plotlyOutput("plot"),
)
)
server <- function(input, output,session) {
choi <-reactive({
if (input$use=="bureau"){
# Can also set the label and select items
return( c("bureau"))}
else if (input$use=="unité"){
return (list$libelle)}
})
observe({
updateSelectInput(session, "inSelect",
label = paste(" "),
choi= choi())
})
output$plot <- renderPlotly({
if (input$use=="bureau"){
table_bureau =tbl_bureau[tbl_bureau$libelle==input$inSelect,]
#Cla moyenne totale de chaque service par jour durant tte la periode ...
table_moy <-table_bureau %>% group_by(jour) %>% summarise(Moyenne = mean(taux))
table_sd <- table_service %>% group_by(jour) %>% summarise(sds=sd(taux))
tbl_service_moy_sds <- merge(table_moy,table_sd, by=c("jour"))
tbl_service_moy_sds<- na.omit(tbl_service_moy_sds)
to_plot <- tbl_service_moy_sds
plot_mois_courant<- tbl_exh_hopital_ser_mois_courant %>% filter(libelle==input$inSelect)
}
to_plot<- na.omit(to_plot)
pp <- ggplot(to_plot, aes(jour)) +
geom_line( aes(x=jour, y=Moyenne, colour = "moyenne"),data=to_plot) +
geom_line(data=plot_mois_courant, aes(x=jour, y=Moyenne, colour = " mois courant"))+
ggtitle(paste0("Evolution de la moyenne: ","''",input$inSelect ,"''"," PSL"))
ggplotly(pp)
})
}
shinyApp(ui, server)
}
Please help me