Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201839

Is there a way to determine which 2 dates a specific date is between? [duplicate]

$
0
0

This question already has an answer here:

I am trying to find out which two date values of a vector a specific date is between. I am not really sure how else to explain it, the example should help more.

## Vector of dates
temp <- seq(as.Date("2000/01/01"),as.Date("2003/01/01"),"years")
temp

[1] "2000/01/01""2001/01/01""2002/01/01""2003/01/01"

date<- sample(seq(as.Date("2000/01/01"),as.Date("2003/01/01"),"days"),1)
date

This should be a random date, but just for the example let say that it is 2002/09/14. How can I go about having date look through temp and find the values that it is between, so for this example, the answer would be c("2002/01/01","2003/01/01").

I am basically looking for something that is the flip of the between function in dplyr.


Viewing all articles
Browse latest Browse all 201839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>