My tbl_df:
> p2p_dt_SKILL_A%>%
+ select(Patch,Date,Prod_DL)%>%
+ head()
Patch Date Prod_DL
1 P1 2015-09-04 3.43
2 P11 2015-09-11 3.49
3 P12 2015-09-18 3.45
...
4 P13 2015-12-06 3.57
5 P14 2015-12-13 3.43
6 P15 2015-12-20 3.47
I want to select all rows
based on the date for example if Date
is greater than 2015-09-04
and less than 2015-09-18
The result should be:
Patch Date Prod_DL
P1 2015-09-04 3.43
P11 2015-09-11 3.49
I tried the following but it returns empty empty vector.
p2p_dt_SKILL_A%>%
select(Patch,Date,Prod_DL)%>%
filter(Date > "2015-09-04" & Date <"2015-09-18")
Just returns:
> p2p_dt_SKILL_A%>%
+ select(Patch,Date,Prod_DL)%>%
+ filter(Date > 2015-09-12 & Date <2015-09-18)
Source: local data table [0 x 3]
Variables not shown: Patch (fctr), Date (date), Prod_DL (dbl)
Also tried with quotes.
And using lubridate
p2p_dt_SKILL_A%>%
select(Patch,Date,Prod_DL)%>%
#filter(Date > 2015-09-12 & Date <2015-09-18)%>%
filter(Patch %in% c("BVG1"),month(p2p_dt_SKILL_A$Date) == 9)%>%
arrange(Date)
But this gives me whole September data.
Is there a more efficient way like using the between
operator from dplyr
on Date
types variables?