我有以下(高度简化)dplyr
示例mutate
:
xx <- data.frame(x = 1:10, y = c(rep(1,4),rep(2,6)))
bla_fun <- function(x,y){cat(x," ",y,"\n"); min(x,y)}
xx %>% rowwise() %>%
mutate( z = bla_fun(x,y))
我想让它使用mutate_at
它可以将列名作为字符串传递给我。
xx %>% rowwise() %>%
mutate_at( c("x","y"), funs("bla_fun") )
但这不起作用。如何让它工作?