Not sure if I gave the correct topic about my question.
Here is the situation I have now
configs
Combines Cols
<chr> <chr>
1 P_AC P_A
2 P_AC P_B
3 P_ABC P_A
4 P_ABC P_B
5 P_ABC P_C
.......
which defines the new columns I want to mutate for my data set, it has columns, such as "P_A, P_B, ...."
I can produce the operation for each new columns I want to add,
configs %>% select(Combines, Cols) %>%
group_by(Combines) %>%
nest() %>%
mutate(eq = map_chr(data, ~paste0(.$Cols,collapse="+"))) %>%
ungroup() %>%
select(Combines, eq)
# A tibble: 2 x 3
Combines eq
<chr> <chr>
1 P_AC P_A+P_C
2 P_ABC P_A+P_B+P_C
I tried to write the pipe as
mydf %>% mutate(!!sym("P_AC") := eval("P_A+P_C")) -> mydf
It did not work, so the question is for equation here I want to evaluate inside "tidyverse" pipe, what is the correct way.
Thanks