I have data that looks like this:

```
library(dplyr)
a<-data_frame(open=as.Date(c("12-31-2016","10-28-2016","08-01-2016"),format=c("%m-%d-%Y")),close=as.Date(c("01-04-2017","01-05-2017","01-01-2017"),format=c("%m-%d-%Y")))
# A tibble: 3 x 2
open       close     
<date>     <date>    
2016-12-31 2017-01-04
2016-10-28 2017-01-05
2016-08-01 2017-01-01

```

I am attempting to create columns that reflect if a given quarter year and quarter is contained in the range between `Open` and `Close`. Thus, in this case there are three quarters and the final data would look like:

```
# A tibble: 3 x 5
 open       close      Q3_2016 Q4_2016 Q1_2017
<date>     <date>       <dbl>   <dbl>   <dbl>
2016-12-31 2017-01-04      0.      1.      1.
2016-10-28 2017-01-05      0.      1.      1.
2016-08-01 2017-01-01      1.      1.      1.

```

I have tried a few different solutions, but none of them seem to be working. Any thoughts?