Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在使用 DBPLYR 访问数据库。但是,我想过滤两组日期。我知道如何在 SQL 中执行此操作,但在 dplyr 或 dbplyr 中不知道。
用于此的 SQL 代码将是
(start_date between date '2017-01-01' and date '2017-03-31') or (start_date between date '2018-01-01' and date '2018-03-31'))
我如何将其转换为 dplyr 语法?
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")