dplyr mutate rowwise max of range of columns

Instead of rowwise(), this can be done with pmax

iris %>%
      mutate(mak=pmax(Sepal.Width,Petal.Length, Petal.Width))

May be we can use interp from library(lazyeval) if we want to reference the column names stored in a vector.

library(lazyeval)
nm1 <- names(iris)[2:4]
iris %>% 
     mutate_(mak= interp(~pmax(v1), v1= as.name(nm1)))

Leave a Comment