Skip to content
Prev 256202 / 398506 Next

Avoiding a loop

2011/4/8 Juan Carlos Borr?s <jcborras at gmail.com>:
You can achieve the same v1 using

v1.2 <-  S[2:N-1] & S[2:N]

.. or if you insist on having NA as the first element, -- c(NA, v1.2)

Vectorization is more efficient than loops but this need not be true
for the *apply functions.