I am really new on dealing with evaluation issues in R.
example<- data.frame(id = 1:5,
pairs0 = c(1, 1, 1, 2, 2),
pairs1 = c(2, 2, 1, 1, 1)
)
Here is the function that I am trying to write:
f <- function(df, col_pair){
df2 <- df %>% mutate(j = row_number())
full_join(df2 %>% select(j, col_pair),
df2 %>% select(j, col_pair),
suffix = c('1', '2'),
by = "{{col_pair}}",
keep = TRUE) %>%
filter(j1 != j2)
}
The function picks a data frame df
and joins it to itself by column col_pair
.
The thing is, if I run f(example, pairs0)
, I get that "join columns must be present in data"
Can someone help?