过滤数据框中的两组日期

时间:2018-06-18 13:51:25

标签: r dplyr dbplyr

我正在使用DBPLYR来访问数据库。但是,我想过滤两组日期。我知道如何在SQL中执行此操作,但不在dplyr或dbplyr中执行此操作。

这个的SQL代码是

ibEgg.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View view, MotionEvent motionEvent) {
                switch (motionEvent.getAction()) {
                    case MotionEvent.ACTION_DOWN:
                        ConstraintLayout.LayoutParams layoutParams = new ConstraintLayout.LayoutParams(250,350);
                        ibEgg.setLayoutParams(layoutParams);
                        return true; // if you want to handle the touch event
                    case MotionEvent.ACTION_UP:
                        ConstraintLayout.LayoutParams layoutParams1 = new ConstraintLayout.LayoutParams(300,400);
                        ibEgg.setLayoutParams(layoutParams1);
                        return true; // if you want to handle the touch event
                }
                return false;
            }
        });

我如何将其转换为dplyr语法?

1 个答案:

答案 0 :(得分:1)

x <- data.frame(date = sample(seq(as.Date('2017/01/01'), as.Date('2018/12/31'), by="day"), 365))

library(dplyr)

x %>%
  filter(date > "2017-01-01" & date < "2017-03-01" |
           date > "2018-01-01" & date < "2018-03-31")