I know that loops are slow in R
and that I should try to do things in a vectorised manner instead.
But, why? Why are loops slow and apply
is fast? apply
calls several sub-functions -- that doesn't seem fast.
Update: I'm sorry, the question was ill-posed. I was confusing vectorisation with apply
. My question should have been,
"Why is vectorisation faster?"
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…