I did mtcars %>% by_row(sum)
but got the message:
by_row()
is deprecated; please use a combination of: tidyr::nest(); d
Furthermore, you can use conditional subsetting, but then you sum up the number of the columns that meet the criterion, not the values:
mtcars %>%
select(all_of(c('gear', 'carb'))) %>%
mutate(
high_gear_carb = rowSums(. > 3)
)
gear carb high_gear_carb
1 4 4 2
2 4 4 2
3 4 1 1
4 3 1 0
5 3 2 0
6 3 1 0
7 3 4 1
...