I stumbled upon a problem with across and rowSums in a single mutate today.
Let's say I have the following two dataframes:
iris1 <- iris %>%
mutate(across(Sepal.Length:Petal.Width, ~ 5 +.x),
sums = rowSums(select(.,Sepal.Length:Petal.Width)))
This does not what I want, because the "." in rowSums(select) selects the "old" values.
iris2 <- iris %>%
mutate(across(Sepal.Length:Petal.Width, ~ 5 +.x)) %>%
mutate(sums = rowSums(select(.,Sepal.Length:Petal.Width)))
This does what I want, but I need to use two mutates. Is there a way on how I can do it in a single mutate?