Slider range doesn't update the table

Hello
I'm working on a small shiny app, and I'm trying to filter the data from the inputs from the slider range.However, the table doesn't change while the slider range has changed.How could I solve the problem?

Below is the UI.R code I've used:

library(shiny)
library(shinythemes)

shinyUI<-fluidPage(
  theme = shinytheme("cerulean"),
  titlePanel("Dashboard"),
    
  sidebarLayout(
    sidebarPanel(
     sliderInput("INVEST","Invest Range:",min = 0,max = 20000,value = c(100,300)),width = 4
   ),
  
  mainPanel(
        tabsetPanel(type = "tabs", tabPanel("customers data", tableOutput("dataset1"))
                
    )
  )
)) 

Below is the SERVER.R code I've used:

library(shiny)
library(RODBC)#for data connection

conn <- odbcDriverConnect("driver={SQL Server};server=;database=;uid=;pwd=")


shinyServer<-function(input, output) {
 
 output$dataset1 <- renderTable ({
   
   conn <- odbcDriverConnect("driver={SQL Server};server=;database=;uid=;pwd=")    
   query <- "SELECT BRKNo,SEX,BIRTHDAY,LAST_DATE,[ADDRESS],TEL_H_1,INVEST,C_Type,WRNT_REG_DATE,WRNT_CNCL_DATE,APL_FLAG,datediff(year,BIRTHDAY,getdate()) AS age
   FROM dbo.SCUST
   WHERE dbo.SCUST.CustNo not in (select custNo FROM dbo.WCKEY) AND [ADDRESS] not like '%testing%' AND [ADDRESS] not like '%XX%'"
   queried <- sqlQuery(channel = conn, query = query)
   dataset1 = queried

   test <- dataset1[input$INVEST[1]:input$INVEST[2],]
   test},include.rownames=FALSE)  
 }

This are character values, try converting them to numeric.

as.numeric(input$INVEST[1]):as.numeric(input$INVEST[2])
1 Like

Thank you for your reply. I tried,but still not working.
The data seems not connecting with the filter. No matter how I adjust the range, the table just doesn't change.

   test <- dataset1[input$INVEST[1]:input$INVEST[2],]
   test},include.rownames=FALSE)  

problem solved by changing the SERVER.R code into below:

    dataset1 = queried
    dataset1[which(dataset1$INVEST<=input$INVEST[2] & dataset1$INVEST>=input$INVEST[1]),]})   

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.