Been trying to do something very simple, but I'm still having troubles with tidyeval. I have a numeric column from a dataframe and want to turn it into a string, let's say:
id code
1 10
2 14
And I want to turn code
into a string in this case, using a function that accepts a column name as argument. I tried many variations and have not been able to do so:
pre_process <- function(df, num_col) {
df <- df %>%
mutate ({{num_col}} := toString({{num_col}}))
Tried using =
instead of :=
, using !!!
, !!
and a couple other but nothing seems to work, if there's no errors what I get is a dataframe like this:
id code
1 "code"
2 "code"
What am I missing? Thanks