Hi there,
I struggle with quosures on something that must have a trivial solution.
I have a function that has an argument, below called a, that may take a vector or a (non-quoted) column name.
Such argument work flawlessly within mutate() calls, but in my case I would like to directly use the argument to build a tibble, so sometimes the argument must be read as a quosure to be evaluated in the initial table, and othertimes it should be evaluated directly. OK, I struggle to explain but the example below should help:
foo <- function(table, a) {
tibble(a = {{a}})
}
tibble(b = 1) %>% foo(a = 1)
tibble(b = 1) %>% foo(a = b) ## does not work... I would like it to give the same output as the line above...
How can I thus modify the code below so that it works as expected?
Thanks!