You mentioned in your question about apply family, and tagged dplyr. Andres already gave a solution using tidyverse, so I'm adding two more solutions using base R.
set.seed(seed = 333)
A_vec <- c(55, 44, 66, 77)
B_df <- data.frame(x = sample(x = 50:59,
size = 10),
y = sample(x = 40:49,
size = 10),
z = sample(x = 60:69,
size = 10),
aa = sample(x = 70:79,
size = 10))
# using mapply
as.data.frame(x = mapply(FUN = function(p, q) replace(x = p,
list = (p <= q),
values = 0),
B_df, A_vec))
#> x y z aa
#> 1 58 46 0 79
#> 2 56 47 0 0
#> 3 0 49 0 0
#> 4 59 0 0 0
#> 5 0 0 68 0
#> 6 57 0 67 0
#> 7 0 45 0 78
#> 8 0 0 69 0
#> 9 0 48 0 0
#> 10 0 0 0 0
# using Map
do.call(cbind.data.frame, Map(f = function(p, q) replace(x = p,
list = (p <= q),
values = 0),
B_df, A_vec))
#> x y z aa
#> 1 58 46 0 79
#> 2 56 47 0 0
#> 3 0 49 0 0
#> 4 59 0 0 0
#> 5 0 0 68 0
#> 6 57 0 67 0
#> 7 0 45 0 78
#> 8 0 0 69 0
#> 9 0 48 0 0
#> 10 0 0 0 0