This is not a very pretty answer, but this is what I use to create zero length vectors:
0[-1] # numeric ""[-1] # character TRUE[-1] # logical 0L[-1] # integer
A literal is a vector of length 1, and [-1] removes the first element from the vector (the only element in this case), leaving the vector with zero elements.
As a bonus, if you need one NA appropriate type:
0[NA] # numeric ""[NA] # character TRUE[NA] # logical 0L[NA] # integer
Aaron McDaid Sep 28 '16 at 15:04 2016-09-28 15:04
source share