You should contemplate the difference between the conventional vectorised and &
the early stopping variant &&
(a1 <- c(FALSE,TRUE,FALSE))
(b2 <- rep(TRUE,3))
a1 & b2
a1 && b2
Also while loops, are useful in R in a rare set of circumstances, its very unlikely that your code wouldn't be more elegant and robust to errors if you made use of R's vectorisation, and/or iteration via apply family or tidyverse purr map functions, as its been said; computers will need to loop, but why should you have to worry about the details ?
more links :
1)https://r4ds.had.co.nz/iteration.html#for-loops-vs.-functionals
2)http://adv-r.had.co.nz/Functional-programming.html