I can\'t find the answer anywhere.
I would like to calculate new variable of data frame which is based on mean of rows.
For example:
data &l
You're looking for
data %>% rowwise() %>% mutate(c=mean(c(a,b))) # id a b c # (dbl) (dbl) (dbl) (dbl) # 1 101 1 2 1.5 # 2 102 2 2 2.0 # 3 103 3 2 2.5
or
library(purrr) data %>% rowwise() %>% mutate(c=lift_vd(mean)(a,b))