Hello
For the shiny app I'm working on, i'm expecting the histogram will refresh after the user adjust the slider as well as the radio button.I tried many ways to update the plot but haven't been successful.
The plot do refresh while adjusting the slider when the radio button stays at
"ALL".But when the radio button changes to others, it appears ERROR:operations are possible only for numeric, logical or complex types.
Is there anyway to solve the problem?
Below is the server.r code I've used:
shinyServer<-function(input, output) {
output$histogramplot<- renderPlot({
filtered1<-reactive({
dataset %>%
filter(dataset$INVEST<=input$INVEST[2],
dataset$INVEST>=input$INVEST[1],
dataset$Age<=input$Age[2],
dataset$Age>=input$Age[1],
dataset$DayTrade == dataset$DayTrade)}
)
filtered2<-reactive({
dataset %>%
filter(dataset$INVEST<=input$INVEST[2],
dataset$INVEST>=input$INVEST[1],
dataset$Age<=input$Age[2],
dataset$Age>=input$Age[1],
dataset$DayTrade<-input$DayTrade)
})
theme_set(theme_classic())
if (input$DayTrade == "All"){
ggplot(filtered1(), aes(Age)) +
geom_bar(aes(fill=SEX),bins = 25)}
else{
ggplot(filtered2(), aes(Age)) +
geom_bar(aes(fill=SEX),bins=25)}
})
Below is the ui.r code I've used:
sidebarPanel(
sliderInput("INVEST",min = 0,max = 5000,value = c(100,300),pre="$",width = "75%"),
sliderInput("Age",min = 0,max = 100,value = c(20,30),width = "75%"),
radioButtons("DayTrade",
choices = c("Yes", "No","All"),
selected = "All",width = "75%")
),
Any help is appreciated