Reputation: 2189
I written a function that classify certain dates as seasons. I have the following variables:
x <- "2014-03-03"
x <- as.Date(x, format = "%Y-%m-%d")
start2014
[1] "2014-09-01"
start2015
[1] "2015-09-01"
But when I try this function:
ifelse((x > start2014 && x < start2015), 1, 0)
I still get:
[1] 0
While it should evaluate to [1]
Any thoughts why this goes wrong?
Upvotes: 0
Views: 47
Reputation: 54247
To my knowledge, 2014-03-03
is not greater 2014-09-01
:
x <- c("2014-03-03", "2014-12-01")
x <- as.Date(x, format = "%Y-%m-%d")
start2014 <- as.Date("2014-09-01")
start2015 <- as.Date("2015-09-01")
ifelse((x > start2014 & x < start2015), 1, 0)
[1] 0 1
Upvotes: 1