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)))
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…