I’m writing a function where I need to pass in a series of columns as the join columns between two tables with the … input to my function.
library(tidyverse)
dat <- diamonds |> head(10)
test_fn <- function(...){
dat1 <- dat
dat2 <- dat
cols <- enquos(...)
col_names <- deparse(cols)
left_join(
dat1
,dat2
,by=join_by(
!!!col_names
)
,relationship="many-to-many"
)
}
Ideally I would use the following inputs test_fn(cut,carat,clarity)
and it would pass a column that joins the tables by cut, carat and clarity.