SLE
SLE

Reputation: 85

Slider input dates non-numeric to binary issue

I am trying to create a sliderinput between these dates in R shiny. Each time, I get this error: Warning: Error in -: non-numeric argument to binary operator [No stack trace available]

and this as output in the app, instead of the slider: non-numeric argument to binary operator

Yet, I have seen countless examples of this (i.e https://github.com/eparker12/nCoV_tracker/blob/master/app.R) , so I do not see why this does not work. I have the libraries Lubridate, Shiny and ShinyWidgets and have updated them to the latest versions.

ui=fluidPage(
  uiOutput("plot_date_page1"),
)

server=function(input,output,session){

output$plot_date_page1<-renderUI({
    sliderInput("plot_date_page1","Date",
                label = h5("Select mapping date"),
                min = as.Date("1980-01-01","%Y-%m-%d"),
                max = as.Date("2020-01-01","%Y-%m-%d"),
                value = as.Date("2020-01-01"),
                timeFormat = "%y %b")
        })

}

shinyApp(ui = ui, server = server)

Upvotes: 0

Views: 240

Answers (1)

mnist
mnist

Reputation: 6956

You made a simple mistake: Date is implicitly considered as the step argument (you specified label explicitly) which makes obviously no sense. What did you want to specify with Date?

ui=fluidPage(
  uiOutput("plot_date_page1"),
)

server=function(input,output,session){

  output$plot_date_page1<-renderUI({
    sliderInput("plot_date_page1",
                # step = "Date",
                label = h5("Select mapping date"),
                min = as.Date("1980-01-01","%Y-%m-%d"),
                max = as.Date("2020-01-01","%Y-%m-%d"),
                value = as.Date("2020-01-01"),
                timeFormat = "%y %b")
  })

}

shinyApp(ui = ui, server = server)

Upvotes: 1

Related Questions