I want a function to glue two character variables together even when the name of one (or many) are not know until the function is called.
f <- function(t, str1, ...) {
t %>%
mutate(name = glue::glue("{str1} {...}"))
}
s <- tidyr::tribble(
~str1, ~str2,
"first", "second"
)
s
s %>% f(str1, str2)
The answer I want is the same as the result of this function and call where I assume the name of the second field is known.
f2 <- function(t, str1, ...) {
t %>%
mutate(name = glue::glue("{str1} {str2}"))
}
s <- tidyr::tribble(
~str1, ~str2,
"first", "second"
)
s
s %>% f2(str1, str2)