This is a logical comparison so the result would be a boolean (TRUE or FALSE), if you want to get 0 or 1 instead use as.numeric()
, see this example.
library(dplyr)
sample_df <- data.frame(
total_hit = 35:45,
total_work = 75:85
)
sample_df %>%
mutate(total_hit_work = as.numeric(total_hit > 40 & total_work > 80))
#> total_hit total_work total_hit_work
#> 1 35 75 0
#> 2 36 76 0
#> 3 37 77 0
#> 4 38 78 0
#> 5 39 79 0
#> 6 40 80 0
#> 7 41 81 1
#> 8 42 82 1
#> 9 43 83 1
#> 10 44 84 1
#> 11 45 85 1
Created on 2021-08-23 by the reprex package (v2.0.1)
If you need more specific help, please provide a proper REPRoducible EXample (reprex) illustrating your issue.