Hi all
I am a while buzzy with making a Shiny
I visualize the data in a ggplot, there are some options (dropdown menu and the checkbox.)
Via a if loop, the checkbox is prioritized above the dropdown menu, it would be more clear if the dropdown menu is greyed-out/disable when the checkbox is checked and re-abled when the checkbox is de-checked.
This is the UI chunk:
tabPanel("Distribution based on SYSTEM", icon = icon("fa-duotone fa-microscope", verify_fa = FALSE),
sidebarLayout(
sidebarPanel(
checkboxInput("all_cobas", label = "Select all and only Cobas", value = FALSE),
selectInput("system", "System:", choices = NULL)),
mainPanel(
plotOutput("barplot3")))),
This is the server chunck:
updateSelectizeInput(session, 'system', choices = df1$InstrumentName, server = TRUE)
output$barplot3 <- renderPlot({
if (input$system!=""){
if(input$all_cobas == TRUE) {
df1_filtered <- df1[grep("cobas", df1$InstrumentName), ]
}
else {
df1_filtered <- df1[df1$InstrumentName == input$system,]
}
#Calculate the amount of Result-samples each hour:
hours_set <- hms(df1_filtered$ResultTime)
df2 <- as.data.frame(hours_set$hour)
df_aggr_Result <- aggregate(df2, by=list(df2$`hours_set$hour`), FUN = length)
#Renaming
names(df_aggr_Result)[names(df_aggr_Result) == "Group.1"] <- "hour"
names(df_aggr_Result)[names(df_aggr_Result) == "hours_set$hour"] <- "amount of samples"
all_h <- tibble(hour = 0:23)
df_plot = merge(x=all_h,y=df_aggr_Result,by="hour",all=TRUE)
df_plot[is.na(df_plot)] <- 0
ggplot(df_plot, aes(x = df_plot$hour, y = df_plot$`amount of samples`)) +
geom_bar(fill = "#0073C2FF", stat = "identity") +
theme(axis.text.x = element_text(face = "bold", color = "#993333", size = 15),
axis.text.y = element_text(face = "bold", color = "#993333", size = 15),
axis.line = element_line(color = "#993333", size = 1)) +
scale_x_continuous(breaks=seq(0,23,1)) +
xlab("Hours in a day") + ylab("Amount of samples")
}
})
I already tried with updatPickerInput(), but it don't work. Are there some different approaches?
Thanks in advance!