I'm trying to calculate the difference between two dates using a dateRangeInput. I can use both of the dates as a value but when I try to subtract them using difftime nothing happens.
Here's my code:
date1 <- input$daterange[2]
date2 <- input$daterange[1]
date3 <- difftime(date2, date1, units = "days")
Here you can see how the value "date3" is blank:
What am I doing wrong here?
EDIT:
Here's the hard coded version. Copy and paste it to try it out. Doesn't work either.
date1 <- as.Date("2016-01-01")
date2 <- as.Date("2017-01-01")
date3 <- difftime(date2, date1, units = "days")