I know that you are asking about how to compare dates in conditionalPanel, but whatever you are trying to do, it will be much easier using renderUI on the server side.
From your question I assume that you have some quarterly reports running and that with the changes of the quarter you want to display different filters / selectInputs.
Below I show a toy example which checks if the chosen input$date is equal to end date of last quarter (round_date(Sys.Date(), "quarter") - days(1))).
Note, that I added library calls to stringr and lubridate.
I further made up a character vector of csv files names, since I cannot reproduce the code you provide.
library("shiny")
library("shinyWidgets")
library("lubridate")
library("stringr")
# made up character vector of csv file names
date_vec <- c("30092019KRB.csv",
"31082019KRB.csv",
"31072019KRB.csv",
"30062019KRB.csv",
"31052019KRB.csv",
"30042019KRB.csv")
shinyApp(
ui = fluidPage( # user interface
sidebarLayout( # layout with Sidebar
sidebarPanel( # input sidebarPanel
selectInput(inputId = 'date',
label = 'Stichtag:',
choices = sub("([0-9]{4}).([0-9]{2}).([0-9]{2})",
"\\3.\\2.\\1",
sort(as.Date(sub("([0-9]{2})([0-9]{2})([0-9]{4})KRB.csv",
"\\1.\\2.\\3",
# below date_vec replaces your list.files() call
date_vec),
format="%d.%m.%Y"),
decreasing = T)
)
) ,
uiOutput("classes")
), # closes sidebarPanel
mainPanel( # Output in mainPabel
) # closes mainPanel
) # closes sidebarLayout
), # closes fluidPage
server = function(input, output) {
output$classes <- renderUI({
# example condition: if input$date is equal to the date of the actual quarter minus 1 day then...
if(dmy(str_remove(input$date, "KRB.csv")) == (round_date(Sys.Date(), "quarter") - days(1))) {
# use show this pickerInput ....
pickerInput(
inputId = "assetclass",
label = "Assetklassen:",
choices = c("class a", "class b", "class c"),
multiple = T
)
# otherwise show this pickerInput ...
} else {
pickerInput(
inputId = "equity",
label = "Equity classes:",
choices = c("class d", "class e", "class f"),
multiple = T
)
}
})
}
) # closes shinyApp
If you prefer conditionalPanel you can build on the approach from Udit (below), but instead writing a JS function you could bring your input vector into the right format and use it as is.
However, if you use the input vector later on the server side you would need to bring it into the old format with some string manipulation.
library("shiny")
library("shinyWidgets")
# made up character vector of csv file names
date_vec <- c("30092019KRB.csv",
"31082019KRB.csv",
"31072019KRB.csv",
"30062019KRB.csv",
"31052019KRB.csv",
"30042019KRB.csv")
choice_vec <- gsub("[-]",
"/",
sort(as.Date(sub("([0-9]{2})([0-9]{2})([0-9]{4})KRB.csv",
"\\3.\\2.\\1",
# below date_vec replaces your list.files() call
date_vec),
format="%Y.%m.%d"),
decreasing = T)
)
names(choice_vec) <- sub("([0-9]{4}).([0-9]{2}).([0-9]{2})",
"\\3.\\2.\\1",
sort(as.Date(sub("([0-9]{2})([0-9]{2})([0-9]{4})KRB.csv",
"\\1.\\2.\\3",
# below date_vec replaces your list.files() call
date_vec),
format="%d.%m.%Y"),
decreasing = T)
)
shinyApp(
ui = fluidPage( # user interface
sidebarLayout( # layout with Sidebar
sidebarPanel( # input sidebarPanel
selectInput(inputId = 'date',
label = 'Stichtag:',
choices = choice_vec
) ,
conditionalPanel(
condition = "new Date('2019/09/30') > new Date(input.date)",
pickerInput(
inputId = "assetclass",
label = "Asset casses:",
choices = c("class a", "class b", "class c"),
multiple = T
)
)
), # closes sidebarPanel
mainPanel( # Output in mainPabel
) # closes mainPanel
) # closes sidebarLayout
), # closes fluidPage
server = function(input, output) {
}
) # closes shinyApp