Skip to content
Prev 38673 / 63424 Next

Surprising behavior of letters[c(NA, NA)]

On 17/12/2010 9:32 AM, Gabor Grothendieck wrote:
This is because  c(NA, NA) is a logical vector, so it gets recycled to 
the length of letters, whereas c(NA, 3) and the others are numeric 
vectors, so they aren't recycled, they're converted to integer indices.  
So the surprise is due to not recognizing that NA is logical.  You 
wouldn't expect a length 1 result from letters[TRUE], would you?

Duncan Murdoch