Reputation: 13
Now that funs is "softly depreciated", I can't figure out this simple task: how would you multiply a range of columns by a constant ?!! In other words, how would you rewrite this using Tidy/DPLYR:
data10x <- mtcars%>% mutate_at(vars(mpg:hp),funs(.*10))
I tried data10x <- mtcars %>% mutate_at(vars(mpg:hp),~(.*10))
but it gives me an error.
I must be losing my mind, but this has to be simple! Thank you!
Upvotes: 0
Views: 1130
Reputation: 887108
It is working fine
library(dplyr)
mtcars %>%
mutate_at(vars(mpg:hp), ~ . * 10)
Or with across
mtcars %>%
mutate(across(mpg:hp, ~ .* 10))
Upvotes: 0