I would like to understand how I can get the row-wise minimum for a set of columns that are defined in a vector of strings, i.e. how to get the following output with the following input:
Input:
t <- data.frame(x= c(1,2,3,4), y= c(2,3,4,5), z = c(4,5,6,7))
vars. <- c('x', 'y')
My (not working) suggestion:
t %>% rowwise %>% mutate(min_x_y = min(vars(vars.)))
Output should be:
x y z min_x_y
1 1 2 4 1
2 2 3 5 2
3 3 4 6 3
4 4 5 7 4