I'm trying to create a shiny dashboard that allows the user to select a csv file. The file contains only two columns that are order number and dateCreated. I want the user to be able to in addition, select the date range that they desire and get a summary count statistic.
So far my code is as follows:
library(shiny) library(plotly) library(colourpicker) library(ggplot2) ui <- fluidPage( titlePanel("Case Referrals"), sidebarLayout( sidebarPanel( fileInput("file", "Select a file"), sliderInput("period", "Time period observed:", min(data()[, c('dateCreated')]), max(data()[, c('dateCreated')]), value = c(min(data[, c('dateCreated')]),max(data()[, c('dateCreated')]))) ), mainPanel( DT::dataTableOutput("table") ) ) ) # Define the server logic server <- function(input, output) { # file input input_file <- reactive({ if (is.null(input$file)) { return("") } }) # summarizing data into counts data <- input_file() data <- subset(data, dateCreated >= input$period[1] & dateCreated <= input$period[2]) output$table <- DT::renderDataTable({ data }) } shinyApp(ui = ui, server = server) I get an error message saying:
Error in data()[, c("dateCreated")] : incorrect number of dimensions
Can anyone help me understand what the problem might be and/or provide a better framework for doing this? And to be clear in the csv file, the createDate variable is broken down into individual days for when the order was placed.
Thank you!