【发布时间】:2021-09-15 12:21:29
【问题描述】:
我很难将 sql 语句转换为 dplyr。 假设我有以下 sql 语句:
select * from table1 t1
left join table2 t2 on t1.id1 = t2.id2
where t2.id is null
dplyr 表示法是:
data <- table1 %>%
left_join(table2, by = c('id1' = 'id2') %>%
filter(is.null(id2))
但是它不起作用。
如何修改我的dplyr 语句以对应上述sql语句?
【问题讨论】:
-
也许这有帮助? dbplyr.tidyverse.org
-
我认为你需要
is.na而不是is.null。试试%>% filter(is.na(id2))