Unable to update value in updateDateInput

I'm making an interactive R Shiny dashboard and I am trying to implement functionality to select a view(Day, Week, Month, Year) and select a starting and ending date value using this code:

observeEvent(input$idCasesDateType, {
    
    cat('View Selection changed!\nSelected - ', input$idCasesDateType, '\n')
    
    switch(
      input$idCasesDateType,
      'Daily' = {
        data <- GetDateData(cases_C, 'day')
        updateDateInput(session, 'minDate_Cases', max = max(data$Date) - 6)
        updateDateInput(session, 'minDate_Cases', value = min(data$Date))
        updateDateInput(session, 'maxDate_Cases', min = min(data$Date) + 6)
        updateDateInput(session, 'maxDate_Cases', value = max(data$Date))
      },
      'Weekly' = {
        data <- GetDateData(cases_C, 'week')
        updateDateInput(session, 'minDate_Cases', max = max(data$Date) - 34)
        updateDateInput(session, 'minDate_Cases', value = min(data$Date))
        updateDateInput(session, 'maxDate_Cases', min = min(data$Date) + 34)
        updateDateInput(session, 'maxDate_Cases', value = max(data$Date))
      },
      'Monthly' = {
        data <- GetDateData(cases_C, 'month')
        updateDateInput(session, 'minDate_Cases', max = max(data$Date) %m-% months(5))
        updateDateInput(session, 'minDate_Cases', value = min(data$Date))
        updateDateInput(session, 'maxDate_Cases', min = min(data$Date) %m+% months(5))
        updateDateInput(session, 'maxDate_Cases', value = max(data$Date))
      },
      'Yearly' = {
        updateDateInput(session, 'minDate_Cases', value = min(cases_C$Date))
        updateDateInput(session, 'maxDate_Cases', value = max(cases_C$Date))
        
        # Disable the input - user cannot select input for the year view
        shinyjs::disable('maxDate_Cases')
      }
    )
    cat(input$minDate_Cases, ' - ', min(data$Date), '\n')
    cat(input$maxDate_Cases, ' - ', max(data$Date), '\n')
  })

The cat statements are what I am trying to use to debug currently because when this section of code executes for the first time, the values of my two reactive values(input$minDate_Cases and input$maxDate_Cases) is empty even though I set them. I get this as my output:

View Selection changed!
Selected -  Daily 
  -  18331 
  -  19155

and on subsequent runs when choosing a different view I get:

View Selection changed!
Selected -  Monthly 
18331  -  18322 
19155  -  19144

This shows that I do have valid data that I am trying to set the values to but they are not being set here and are not being updated when I change the selected view.

Could you format this into a reproducible example? That is a set of code or rstudio.cloud project that folks can easily get up and running to replicate your issue? Currently, this is only part of a shiny app.

IF you aren't familiar with best practices for shiny reprexes, check out

This will make it easier for folks to replicate your issue and offer suggestions to solve it.

I have the project and dependent data and R files stored in a github repo. I will see about making a reprex but it will probably take a while to make it smaller and actually work because my current project is the main app.R file, three other .R files and two excel files, one of which has over 120,000 rows.

I used the browser() function to pause the execution to see the value of input$minDate_Cases and input$maxDate_Cases and they were NULL even directly after executing updateDateInput(session, 'minDate_Cases', max = max(data$Date) - 6, value = min(data$Date)) for example. This tells me that for some reason that I can't figure out, the value is not being set even though it should be getting set.

That could possibly be a red herring, shiny is all about interactions between R server code, and javascript browser code. When you are in an observEvent doing 'update' type events, this creates shiny message events that get queued up to go to the javascript side, they dont directly change internal directly accessable shiny objects. Here is a trivial example, where everything clearly updates on click no problem. but you can browse and the values are static till the shiny server gets opportunity to flush, and update.

library(shiny)

ui <- fluidPage(
  dateInput("myinput",label="an input",
            value=Sys.Date()),
  actionButton("updateme","updateme")
)

server <- function(input, output, session) {
  
  observeEvent(input$updateme,
          {     
            browser()
               print(input$myinput)
               updateDateInput(session=session,
                               inputId = "myinput",
                               label = paste0("an input", input$updateme),
                               value=input$myinput-1)
               #wont change until shiny goes through a flush
               print(input$myinput)
               }
               )
}

shinyApp(ui, server)

if you have a widget that is not updating when the code to update is being run, check that the inputId's match / are correct. and check that the values its being asked to take are acceptable.
Also I did notice some seemingly redundant code, when you create an update* you have opportunity to set more than one attribute at time i.e. instead of

        updateDateInput(session, 'minDate_Cases', max = max(data$Date) - 6)
        updateDateInput(session, 'minDate_Cases', value = min(data$Date))
        updateDateInput(session, 'minDate_Cases', max = max(data$Date) - 6, value = min(data$Date))

hmmm, on reflection seems like you are setting the max to be 6 less than the min. perhaps this is causing an issue.

I've realized that the reason I was getting NULL for my values in the observeEvent is because it is running before my renderUI functions so those date inputs don't actually exist yet. This doesn't really solve the issue I am having though.

I don't know if you have attempted to download and run the app from the GitHub repo, but when changing the view selection(Daily, Weekly, Monthly, Yearly), it renders the plot once using the old dates and then renders it again with the correct dates. The first render and when changing to Yearly are the only renders that works fine because the render waits for the input values to be set on the first run and for Yearly I disable the date inputs for those specific graphs.

I have removed the observeEvent for idCasesDateType since it's functionality was sort of useless and repeated elsewhere anyway. I used the browser() function inside my renderPlotly function and it gets called twice after changing the selected view; the first time with the old input dates and the second time with the correct input dates. This can be seen in the graph rendering, particularly with months because it will render starting with April 2020(I don't know why) and then render again from March 2020 which is the correct start.

In response to the redundant code, I did that because while researching this issue I found a response saying that:

The problem is that updateDateInput appears to make changes that aren't atomic . That is, they don't occur all at once, but rather sequentially. Therefore, when changing more than one parameter of the input widget at at time, it's possible that the value is momentarily invalid.

I have since changed it back to the one-line which you also did.

hmmm, on reflection seems like you are setting the max to be 6 less than the min. perhaps this is causing an issue.

So in this line:
'Daily' = updateDateInput(session, 'maxDate_Cases', min = input$minDate_Cases + 6)
I am updating the minimum value of maxDate_Cases to six(6) more than the current start date(input$minDate_Cases) so that 1) The selected end date can not be lower than the selected start date and 2) There will always be seven(7) days or more of data displayed in the graph.

I also pushed these changes to GitHub.

Since my renderPlotly function doesn't run until req(input$minDate_Cases, input$maxDate_Cases, input$idCasesDateType) passes, is there a way to flush the old values of input$minDate_Cases and input$maxDate_Cases once input$idCasesDateType is changed in order to force renderPlotly to wait until the renderUI functions complete?

I could be way off, because i find the way this discussions moves around without concrete referents, such as a solid reprex with a clear issue to resolve hard to follow. Have we moved now from solving updates to controlling how we react to downdtream consequences of updates ?

It s3ems like you are asking for advice on how to limit redraw events on a render function that may have many inputs likely to change rapidly close in time together .

That being my assumption, I think the cannonical solution is to create a reactive object that would be responsible for gathering the inputs (and so it alone gets passed to the render which unpacks its contents), and for that single carrier to be debounced, i.e. when first triggered by any change, to wait a small amount before relying on the value as it may change. I woild use shiny debounce for that

The issue has been that the graphs render twice because the value of the dateInputs are updated after the plot renders. I created a working reprex so you can hopefully run it and see the issue:

library(plotly)
library(lubridate)
library(dplyr)

x <- as.Date(as.character(20200310), format = '%Y%m%d')
df <- data.frame('Date' = seq.Date(x, x + 100, by = 'day'), 'Cases' = sample(1:100, 101, replace = TRUE))

ui <- {
  fluidPage(
    fluidRow(
      column(width = 12, selectInput('viewSelection', 'View', c('Daily', 'Weekly', 'Monthly'), 'Daily')),
      column(width = 1, align = 'center', uiOutput('startDate'), uiOutput('endDate')), column(width = 10, plotlyOutput('myPlotly', height = '500px'))
    )
  )
}

server <- function(input, output, session) {
  # Update the start date input based on the selected view
  output$startDate <- renderUI({
    req(input$viewSelection)
    switch (
      input$viewSelection,
      'Daily' = {
        data <- df %>% group_by(Date = floor_date(Date, 'day')) %>% summarize(Cases = sum(Cases))
        dateInput('startDate', 'Start Date', value = min(data$Date), min = min(data$Date), max = max(data$Date), format = 'mm/dd/yyyy', startview = 'month')
      },
      'Weekly' = {
        data <- df %>% group_by(Date = floor_date(Date, 'week')) %>% summarize(Cases = sum(Cases))
        dateInput('startDate', 'Start Date', value = min(data$Date), min = min(data$Date), max = max(data$Date), format = 'mm/dd/yyyy', startview = 'month', daysofweekdisabled = c(1, 2, 3, 4, 5, 6))
      },
      'Monthly' = {
        data <- df %>% group_by(Date = floor_date(Date, 'month')) %>% summarize(Cases = sum(Cases))
        min_date <- as.Date(min(floor_date(data$Date, 'month')))
        max_date <- as.Date(max(ceiling_date(data$Date, 'month'))) - 1
        dateInput('startDate', 'Start Date', value = min_date, min = min_date, max = max_date, format = 'M, yyyy', startview = 'month')
      }
    )
  })
  # Update the end date input based on the selected view
  output$endDate <- renderUI({
    req(input$viewSelection)
    switch (
      input$viewSelection,
      'Daily' = {
        data <- df %>% group_by(Date = floor_date(Date, 'day')) %>% summarize(Cases = sum(Cases))
        dateInput('endDate', 'End Date', value = max(data$Date), min = min(data$Date), max = max(data$Date), format = 'mm/dd/yyyy', startview = 'month')
      },
      'Weekly' = {
        data <- df %>% group_by(Date = floor_date(Date, 'week')) %>% summarize(Cases = sum(Cases))
        dateInput('endDate', 'End Date', value = max(data$Date), min = min(data$Date), max = max(data$Date), format = 'mm/dd/yyyy', startview = 'month', daysofweekdisabled = c(1, 2, 3, 4, 5, 6))
      },
      'Monthly' = {
        data <- df %>% group_by(Date = floor_date(Date, 'month')) %>% summarize(Cases = sum(Cases))
        min_date <- as.Date(min(floor_date(data$Date, 'month')))
        max_date <- as.Date(max(ceiling_date(data$Date, 'month'))) - 1
        dateInput('endDate', 'End Date', value = max_date, min = min_date, max = max_date, format = 'M, yyyy', startview = 'month')
      }
    )
  })
  
  # Render the plot for the data using the selected inputs
  output$myPlotly <- renderPlotly({
    req(input$viewSelection, input$startDate, input$endDate)
    switch (
      input$viewSelection,
      'Daily' = {
        data <- df %>% group_by(Date = floor_date(Date, 'day')) %>%
          filter(as.Date(Date) >= as.Date(input$startDate) & as.Date(Date) <= as.Date(input$endDate)) %>% #Filter data to be between selected dates
          summarize(Cases = sum(Cases))
      },
      'Weekly' = {
        data <- df %>% group_by(Date = floor_date(Date, 'week')) %>%
          filter(as.Date(Date) >= as.Date(input$startDate) & as.Date(Date) <= as.Date(input$endDate)) %>% #Filter data to be between selected dates
          summarize(Cases = sum(Cases))
      },
      'Monthly' = {
        data <- df %>% group_by(Date = floor_date(Date, 'month')) %>%
          filter(as.Date(Date) >= as.Date(input$startDate) & as.Date(Date) <= as.Date(input$endDate)) %>% #Filter data to be between selected dates
          summarize(Cases = sum(Cases))
      }
    )
    plot_ly(
      data,
      x = ~ Date,
      y = ~ Cases,
      type = 'scatter',
      mode = 'lines'
    )
  })
}

# Run the application 
shinyApp(ui = ui, server = server)

I do realize this is still a lot of code, but it demonstrates my issue when run and is only 93 lines compared to my current app which is around 1000 lines in just the app.R file.

I did not code in the safety of selecting valid dates(aka, selecting a start date that is past the end date), but you should be able to see that when you change views from Daily to Monthly for example, it will render the plot then quickly render it again. This is because the plot renders with the old input values then renders again when it realizes that the input values changed.

Would you be able to give an example of that in the context of what I am doing?

I split the original renderplotly into 3 parts

library(plotly)
library(lubridate)
library(shiny)
library(tidyverse)

x <- as.Date(as.character(20200310), format = '%Y%m%d')
df <- data.frame('Date' = seq.Date(x, x + 100, by = 'day'), 'Cases' = sample(1:100, 101, replace = TRUE))

ui <- {
  fluidPage(
    fluidRow(
      column(width = 12, selectInput('viewSelection', 'View', c('Daily', 'Weekly', 'Monthly'), 'Daily')),
      column(width = 1, align = 'center', uiOutput('startDate'), uiOutput('endDate')), column(width = 10, plotlyOutput('myPlotly', height = '500px'))
    )
  )
}

server <- function(input, output, session) {
  # Update the start date input based on the selected view
  output$startDate <- renderUI({
    req(input$viewSelection)
    switch (
      input$viewSelection,
      'Daily' = {
        data <- df %>% group_by(Date = floor_date(Date, 'day')) %>% summarize(Cases = sum(Cases))
        dateInput('startDate', 'Start Date', value = min(data$Date), min = min(data$Date), max = max(data$Date), format = 'mm/dd/yyyy', startview = 'month')
      },
      'Weekly' = {
        data <- df %>% group_by(Date = floor_date(Date, 'week')) %>% summarize(Cases = sum(Cases))
        dateInput('startDate', 'Start Date', value = min(data$Date), min = min(data$Date), max = max(data$Date), format = 'mm/dd/yyyy', startview = 'month', daysofweekdisabled = c(1, 2, 3, 4, 5, 6))
      },
      'Monthly' = {
        data <- df %>% group_by(Date = floor_date(Date, 'month')) %>% summarize(Cases = sum(Cases))
        min_date <- as.Date(min(floor_date(data$Date, 'month')))
        max_date <- as.Date(max(ceiling_date(data$Date, 'month'))) - 1
        dateInput('startDate', 'Start Date', value = min_date, min = min_date, max = max_date, format = 'M, yyyy', startview = 'month')
      }
    )
  })
  # Update the end date input based on the selected view
  output$endDate <- renderUI({
    req(input$viewSelection)
    switch (
      input$viewSelection,
      'Daily' = {
        data <- df %>% group_by(Date = floor_date(Date, 'day')) %>% summarize(Cases = sum(Cases))
        dateInput('endDate', 'End Date', value = max(data$Date), min = min(data$Date), max = max(data$Date), format = 'mm/dd/yyyy', startview = 'month')
      },
      'Weekly' = {
        data <- df %>% group_by(Date = floor_date(Date, 'week')) %>% summarize(Cases = sum(Cases))
        dateInput('endDate', 'End Date', value = max(data$Date), min = min(data$Date), max = max(data$Date), format = 'mm/dd/yyyy', startview = 'month', daysofweekdisabled = c(1, 2, 3, 4, 5, 6))
      },
      'Monthly' = {
        data <- df %>% group_by(Date = floor_date(Date, 'month')) %>% summarize(Cases = sum(Cases))
        min_date <- as.Date(min(floor_date(data$Date, 'month')))
        max_date <- as.Date(max(ceiling_date(data$Date, 'month'))) - 1
        dateInput('endDate', 'End Date', value = max_date, min = min_date, max = max_date, format = 'M, yyyy', startview = 'month')
      }
    )
  })
  
  data <- reactive({
    req(input$viewSelection, input$startDate, input$endDate)
    switch (
      input$viewSelection,
      'Daily' = {
        data <- df %>% group_by(Date = floor_date(Date, 'day')) %>%
          filter(as.Date(Date) >= as.Date(input$startDate) & as.Date(Date) <= as.Date(input$endDate)) %>% #Filter data to be between selected dates
          summarize(Cases = sum(Cases))
      },
      'Weekly' = {
        data <- df %>% group_by(Date = floor_date(Date, 'week')) %>%
          filter(as.Date(Date) >= as.Date(input$startDate) & as.Date(Date) <= as.Date(input$endDate)) %>% #Filter data to be between selected dates
          summarize(Cases = sum(Cases))
      },
      'Monthly' = {
        data <- df %>% group_by(Date = floor_date(Date, 'month')) %>%
          filter(as.Date(Date) >= as.Date(input$startDate) & as.Date(Date) <= as.Date(input$endDate)) %>% #Filter data to be between selected dates
          summarize(Cases = sum(Cases))
      }
    )
    data
  })
  
  data_db <- debounce(data,millis = 300)
  
  # Render the plot for the data using the selected inputs
  output$myPlotly <- renderPlotly({
   data <- req(data_db())
    plot_ly(
      data,
      x = ~ Date,
      y = ~ Cases,
      type = 'scatter',
      mode = 'lines'
    )
  })
}

# Run the application 
shinyApp(ui = ui, server = server)
1 Like

This worked very well on it's own, but either a)I broke it while trying to adapt it to mine or b)this didn't resolve the issue. Here is my implementation of what you suggested:

library(plotly)
library(lubridate)
library(dplyr)

GroupDatesLimited <- function(temp, from, to, date_type = 'day') {
  x <- temp %>%
    group_by(Date = floor_date(Date, date_type)) %>%
    filter(as.Date(Date) >= as.Date(from) & as.Date(Date) <= as.Date(to)) %>%
    summarize(Cases=sum(Cases))
  
  return(x)
}
GroupDates <- function(temp, date_type = 'day') {
  x <- temp %>%
    group_by(Date = floor_date(Date, date_type)) %>%
    summarize(Cases=sum(Cases))
  
  return(x)
}
MakePlotlyLine <- function(df, x, y) {
  p <- plot_ly(
    df,
    x = ~x,
    y = ~y,
    type = 'scatter',
    mode = 'lines'
  )
}
MakePlotlyBar <- function(df, x, y) {
  p <- plot_ly(
    df,
    x = ~x,
    y = ~y,
    type = 'bar',
    text = ~format(y, big.mark = ','),
    textposition = 'outside',
    textfont = list(color = '#000000')
  )
}

x <- as.Date(as.character(20200310), format = '%Y%m%d')
df <- data.frame('Date' = seq.Date(x, x + 100, by = 'day'), 'Cases' = sample(1:100, 101, replace = TRUE))

ui <- {
  fluidPage(
    fluidRow(
      column(width = 12, selectInput('selectedView', 'View', c('Daily', 'Weekly', 'Monthly'), 'Daily')),
      column(width = 1, align = 'center', uiOutput('startDate_Cases'), uiOutput('endDate_Cases')), column(width = 10, plotlyOutput('myPlotly', height = '500px'))
    )
  )
}

server <- function(input, output, session) {
  # Update the start date input based on the selected view
  output$startDate_Cases <- renderUI({
    req(input$selectedView)
    switch (
      input$selectedView,
      'Daily' = {
        data <- GroupDates(df, 'day')
        dateInput('startDate_Cases', 'Start Date', value = min(data$Date), min = min(data$Date), max = max(data$Date), format = 'mm/dd/yyyy', startview = 'month')
      },
      'Weekly' = {
        data <- GroupDates(df, 'week')
        dateInput('startDate_Cases', 'Start Date', value = min(data$Date), min = min(data$Date), max = max(data$Date), format = 'mm/dd/yyyy', startview = 'month', daysofweekdisabled = c(1, 2, 3, 4, 5, 6))
      },
      'Monthly' = {
        data <- GroupDates(df, 'month')
        min_date <- as.Date(min(floor_date(data$Date, 'month')))
        max_date <- as.Date(max(ceiling_date(data$Date, 'month'))) - 1
        dateInput('startDate_Cases', 'Start Date', value = min_date, min = min_date, max = max_date, format = 'M, yyyy', startview = 'month')
      }
    )
  })
  # Update the end date input based on the selected view
  output$endDate_Cases <- renderUI({
    req(input$selectedView)
    switch (
      input$selectedView,
      'Daily' = {
        data <- GroupDates(df, 'day')
        dateInput('endDate_Cases', 'End Date', value = max(data$Date), min = min(data$Date), max = max(data$Date), format = 'mm/dd/yyyy', startview = 'month')
      },
      'Weekly' = {
        data <- GroupDates(df, 'week')
        dateInput('endDate_Cases', 'End Date', value = max(data$Date), min = min(data$Date), max = max(data$Date), format = 'mm/dd/yyyy', startview = 'month', daysofweekdisabled = c(1, 2, 3, 4, 5, 6))
      },
      'Monthly' = {
        data <- GroupDates(df, 'month')
        min_date <- as.Date(min(floor_date(data$Date, 'month')))
        max_date <- as.Date(max(ceiling_date(data$Date, 'month'))) - 1
        dateInput('endDate_Cases', 'End Date', value = max_date, min = min_date, max = max_date, format = 'M, yyyy', startview = 'month')
      }
    )
  })
  
  cases <- reactive({
    req(input$selectedView, input$startDate_Cases, input$endDate_Cases)
    cat('selectedView- ', input$selectedView, '\n')
    switch (
      input$selectedView,
      'Daily'   = cases <- GroupDatesLimited(df, input$startDate_Cases, input$endDate_Cases, 'day'),
      'Weekly'  = cases <- GroupDatesLimited(df, input$startDate_Cases, input$endDate_Cases, 'week'),
      'Monthly' = cases <- GroupDatesLimited(df, input$startDate_Cases, input$endDate_Cases, 'month')
    )
    cases
  })
  
  cases_db <- debounce(cases, millis = 300)
  
  # Render the plot for the data using the selected inputs
  output$myPlotly <- renderPlotly({
    data <- req(cases_db())
    
    switch(
      input$selectedView,
      'Daily' = MakePlotlyLine(data, data$Date, data$Cases),
      'Weekly' = MakePlotlyLine(data, data$Date, data$Cases),
      'Monthly' = MakePlotlyBar(data, data$Date, data$Cases)
    )
  })
}

# Run the application 
shinyApp(ui = ui, server = server)

I put a cat statement in the reactive to see how many times it was called and besides the first run, it gets called twice. Sorry if I'm just dumb and broke it, everything I'm doing with R and Shiny has been self taught over the past month or so.

P.S. I changed the data <- reactive() to cases <- reactive() because I have 3 graphs that I am doing this with that all rely on different data sources.

you had myPlotly dependent not only on cases but also on input$selectedView , so it could potentially run twice; to allow the changes to come through as a block, I extended the debounced cases_db to also contain the input$selectedView it used , so that myplotly doesnt need to take it on as a separate dependency.


  cases <- reactive({
    req(input$selectedView, input$startDate_Cases, input$endDate_Cases)
    cat('selectedView- ', input$selectedView, '\n')
    switch (
      input$selectedView,
      'Daily'   = cases <- GroupDatesLimited(df, input$startDate_Cases, input$endDate_Cases, 'day'),
      'Weekly'  = cases <- GroupDatesLimited(df, input$startDate_Cases, input$endDate_Cases, 'week'),
      'Monthly' = cases <- GroupDatesLimited(df, input$startDate_Cases, input$endDate_Cases, 'month')
    )
    list(cases=cases,
         iselview=input$selectedView)
  })
  
  cases_db <- debounce(cases, millis = 300)
  
  # Render the plot for the data using the selected inputs
  output$myPlotly <- renderPlotly({
    cdb <- req(cases_db())
    data <- cdb$cases
    iselview <- cdb$iselview
    switch(
      iselview,
      'Daily' = MakePlotlyLine(data, data$Date, data$Cases),
      'Weekly' = MakePlotlyLine(data, data$Date, data$Cases),
      'Monthly' = MakePlotlyBar(data, data$Date, data$Cases)
    )
  })
1 Like

After a while of playing around with this new suggestion, I think I finally got it working on my implementation. You're idea was great! I just had to adapt it a little.

I ended up making just one big reactive to get the values for all 3 graphs:

dateData <- reactive({
    req(input$selectedView, input$startDate_Cases, input$endDate_Cases, input$startDate_Symp, input$endDate_Symp, input$startDate_Asymp, input$endDate_Asymp)
    
    switch (
      input$selectedView,
      'Daily'   = {
        cases <- GetDateLimitedData(cases_C, input$startDate_Cases, input$endDate_Cases, 'day')
        symp  <- GetDateLimitedData(symptomatic_C, input$startDate_Symp, input$endDate_Symp, 'day')
        asymp <- GetDateLimitedData(asymptomatic_C, input$startDate_Asymp, input$endDate_Asymp, 'day')
      },
      'Weekly'  = {
        cases <- GetDateLimitedData(cases_C, input$startDate_Cases, input$endDate_Cases, 'week')
        symp  <- GetDateLimitedData(symptomatic_C, input$startDate_Symp, input$endDate_Symp, 'week')
        asymp <- GetDateLimitedData(asymptomatic_C, input$startDate_Asymp, input$endDate_Asymp, 'week')
      },
      'Monthly' = {
        cases <- GetDateLimitedData(cases_C, input$startDate_Cases, input$endDate_Cases, 'month')
        symp  <- GetDateLimitedData(symptomatic_C, input$startDate_Symp, input$endDate_Symp, 'month')
        asymp <- GetDateLimitedData(asymptomatic_C, input$startDate_Asymp, input$endDate_Asymp, 'month')
      },
      'Yearly'  = {
        cases <- GetDateData(cases_C, 'year')
        symp  <- GetDateData(symptomatic_C, 'year')
        asymp <- GetDateData(asymptomatic_C, 'year')
      }
    )
    list(cases=cases, symp=symp, asymp=asymp, iselview=input$selectedView)
  })

I also had to increase the debounce from 300 to 1000 because it was still going through too quickly and rendering twice.

Thank you so much for all your help. I don't think I could have ever come up with this on my own.

Happy that we found an approach that works for you

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.