In R code example 1:
mat <- matrix(1, nrow = 4, ncol = 4)
avec <- c(2, 3)
mat[avec, avec] <- 0
mat is:
1 1 1 1
1 0 0 1
1 0 0 1
1 1 1 1
But in example 2:
res <- avec + avec
res is (4, 6)
In other words, in example 1, recycling avec generates the pairs (2, 2), (2, 3), (3, 2), and (3, 3), while in example 2, the pairs are (2, 2) and (3, 3). Isn't the recycling inconsistent in these two examples?