iris = iris %>%
let(
new_median = median_row(Sepal.Length, Sepal.Width, Petal.Length, Petal.Width),
new_mean = mean_row(Sepal.Length, Sepal.Width, Petal.Length, Petal.Width)
)
dfs = data.frame(
test = 1:5,
aa = rep(10, 5),
b_ = rep(20, 5),
b_1 = rep(11, 5),
b_2 = rep(12, 5),
b_4 = rep(14, 5),
b_5 = rep(15, 5)
)
# calculate sum of b* variables
dfs %>%
let(
b_total = sum_row(b_, b_1 %to% b_5)
) %>%
print()
# conditional modification
dfs %>%
let_if(test %in% 2:4,
b_total = sum_row(b_, b_1 %to% b_5)
) %>%
print()
Run the code above in your browser using DataLab