0

this part of my program needs to have two inputs 1) the user and 2) the date range selected affect the displayed plot output. Right now, the displayed plot output is just blank. There are no errors listed in my console.

My csv file has the "Date" Column in the format: 03/14/12.

Thank you for any help or observations.

library(shinydashboard)
library(shiny)
library(ggplot2)
library(gridExtra)
library(dplyr)
library(tidyverse)
library(lubridate)

ui <- dashboardPage(
  dashboardHeader(title = "T"),
  dashboardSidebar(),
  dashboardBody(

fluidRow(

  box(
    title = "Controls",
    selectInput("User",
                "User:",
                c("All",
                  unique(as.character(df$User))))

  ), 
  box(
    dateRangeInput("dates", 
                   "Date range",
                   start = "01-01-2018",
                   end = "06-25-2018")
  ),

  mainPanel(

    tabsetPanel(type = "tabs",
                tabPanel("Plot", plotOutput("plot")

          )
        )          
      )
    )
  )
)
  server <- function(input, output){
    df <- read.csv(file = "c:/T/T/T.csv", header = TRUE, sep = ",")
      df$Date <- as.Date(df$Date)


      begin<- reactive({input$dates[1]})
      finish<- reactive({input$dates[2]})

  output$plot <- renderPlot({
    df.filtered <- df %>% 
    filter(df$User == input$User) %>%
    filter(Date >= begin(), Date <= finish())
    req(df.filtered) 

    df.filtered %>% 
    ggplot(aes(DfM, SvM, colour = User)) +
    geom_point(show.legend = FALSE) +
    directlabels::geom_dl(aes(label = User), method = "smart.grid")

    shinyApp(ui, server)
  • You don't create any sort of plot in your `renderPlot()` call. You just seem to return the data. You need to call a plotting function of some sort what will actually draw a plot. What type of plot are you trying to draw? – MrFlick Jun 25 '18 at 19:54
  • @MrFlick, I've updated the code to reflect the final, desired state of the plot. When I run this code, I receive the error "Warning in min(df$Date) : no non-missing arguments to min; returning Inf". Should I have an output other than renderPlot? – user9371177 Jun 25 '18 at 20:05
  • Sounds like the `as.Date(df$Date)` line didn't work. What does your data actually look like? Try `as.Date("03/14/12")` -- that should be returning an error. When asking for help, you should include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and desired output that can be used to test and verify possible solutions. – MrFlick Jun 25 '18 at 20:13

0 Answers0