0
votes

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!

1
It is working fine for me Please show your dplyr package version - akrun
also: show your error message? - Ben Bolker
It works now, weird! - HerrDoktor

1 Answers

0
votes

It is working fine

 library(dplyr)
 mtcars %>%
      mutate_at(vars(mpg:hp), ~ . * 10)

Or with across

mtcars %>%
     mutate(across(mpg:hp, ~ .* 10))