From f240676f07a95ff9251e548cf6abc37f03566b36 Mon Sep 17 00:00:00 2001 From: Ben Schneider Date: Wed, 12 May 2021 13:26:20 -0400 Subject: [PATCH] Skip the `___retained` variable and just filter on the expression. Also conditionally remove the `___row_number` variable if it's not already removed internally by `filter()`. --- R/join.R | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/R/join.R b/R/join.R index da296b8..6211c8f 100644 --- a/R/join.R +++ b/R/join.R @@ -21,9 +21,10 @@ semi_join.tbl_svy <- function( na_matches = na_matches, ...) - x <- mutate(x, `___retained` = `___row_number` %in% filtered_vars[['___row_number']]) - x <- filter(x, .data$`___retained`) - x <- select(x, -.data$`___retained`) + x <- filter(x, .data$`___row_number` %in% filtered_vars[['___row_number']]) + if ("___row_number" %in% tbl_vars(x)) { + x <- select(x, -`___row_number`) + } x @@ -52,9 +53,10 @@ anti_join.tbl_svy <- function( na_matches = na_matches, ...) - x <- mutate(x, `___retained` = `___row_number` %in% filtered_vars[['___row_number']]) - x <- filter(x, `___retained`) - x <- select(x, -`___retained`) + x <- filter(x, .data$`___row_number` %in% filtered_vars[['___row_number']]) + if ("___row_number" %in% tbl_vars(x)) { + x <- select(x, -`___row_number`) + } x