How to detect a blank input for a date in Shiny

Viewed 5434

I have a series of inputs in my R Shiny app that I am using as arguments to a function to select specific data from a data frame. On of the inputs is dateInput:

dateInput("dateSelect", "Date", format = "yyyy-mm-dd", value = NA)

In my function, I need to specify if dateSelect is blank or not selected, to be able select All dates. See an example that is working correctly, that isn't a date, and a simple selectInput:

selectInput("teamSelect", "Team", choices = c("All", levels(newEffortstable$team)))

In the function, this works to select 'All teams':

    if(!missing(teamSelect)){
    if(teamSelect!="All"){
    selections[["teamEfforts"]] = 
    newEffortstable$effortNo[which(newEffortstable$team %in% teamSelect)]
    }else{
    selections[["teamEfforts"]] = newEffortstable$effortNo
    }
    }

I have tried the following with NA and NULL and " " and keep getting 'Error in if: argument is of length zero'

    if(!missing(dateSelect)){
    if(!dateSelect== "NA"){
    selections[["dateEfforts"]] = 
    newEffortstable$effortNo[which(newEffortstable$date == dateSelect)]
    }else{
    selections[["dateEfforts"]] = newEffortstable$effortNo
    }
    }

Thanks!

1 Answers
Related