Hi,
I would like to divide a set of columns by another set of columns, both to be found in my dataset.
For this, I use the mutate-across combo, but while I'm able to select my numerator (with "." (dot) , I am not able to select the denominator, which would be also columns in my dataset but outside the columns I am operating on (.cols).
df <- df %>%
mutate(across(.cols = starts_with("column_set1_prefix_"), .fns = ~. / column_set2, .names = "some_prefix_"))
I tried it by nesting a second "across()" function in the .fns argument of the first across() function, but that somehow made my saved data.frame extremely slow as something would have happened, what should now have happened.
I tried it like that:
df <- df %>%
mutate(across(
.cols = starts_with("column_set1_prefix_"),
".fns = ~ . / across(.cols = starts_with("column_set2_prefix_"), .fns. = identity)))
Could you help me, please, find out, how to select columns that are in my df, but outside the columns I'm operating on in my first across function call?
Kind regards,
Matt