Automatically genrates date inputs for all date variables in a dataframe.

autoinput_date(.df)

Arguments

.df

Dataframe with N variables (one or more should be date)

Value

dateInput() for all the date variables.

Details

Based on the date columns on a dataframe, this function generates all the date inputs. The min/max value on the dataframe is the min/max value on the date input.

Examples

## Only run this example in interactive R sessions
if (interactive()) {
library(shiny)
library(shinymatic)
load('data/customers.rda')
ui <- fluidPage(
  h3('UI (inputs)'),
  autoinput_date(.df = customers),
  h3('Server (output)'),
  verbatimTextOutput(outputId = 'values')
)
server <- function(input, output) {
  output$values <- reactive({
    vars_num <- names(customers)[sapply(customers, class) == "Date"]
    paste0(sapply(
      vars_num,
      FUN = function(i)
        paste(i, "=", input[[i]])
    ),
    collapse = '\n')
  })
}
shinyApp(ui = ui, server = server)
}
#> Warning: cannot open compressed file 'data/customers.rda', probable reason 'No such file or directory'
#> Error in readChar(con, 5L, useBytes = TRUE): cannot open the connection