How to updating within sapply (to avoid for loop)

This is an example where you a for loop is actually more appropriate than *apply because you want the side effect.

for loops used to be slow last century, but the main reason they're avoided now is that a vectorized solution might be available.

4 Likes