Skip to content
Prev 201755 / 398506 Next

Best way to preallocate numeric NA array?

Douglas Bates wrote:
Thanks--good questions.  For any code, I'd order the requirements like this:

1) Correct
2) Readable
3) Space efficient
4) Time efficient

Compromises are sometimes necessary.  R is such an odd language that it
really helps readability to settle on easily recognizable idioms.
That's true in any language where there's more than one way to do things
but I find it especially true in R.  I agree that the efficiency of this
operation only matters with very large vectors or very many repetitions.