How to updating within sapply (to avoid for loop)

Thanks for the response!

I understand what you're saying, but is that a strict no? I mean, is there no way to update using the apply family? For my original problem, the for loop works, but it's really slow.

I've come across this many times, but I don't really know what it means. What exactly is a "vectorized code"? I know there's also a function Vectorize, which is supposed to vectorize a function, but I don't know what it does actually.

If sapply is not applicable, is there any alternative "vectorized" code which will be faster than loops to update something?