Skip to content

vector(NA, 3) (PR#1541)

2 messages · Brian Ripley

#
On Sat, 11 May 2002 pgilbert@bank-banque-canada.ca wrote:

            
It's an incorrect use!
mode: A character string giving an atomic mode, or `"any"'.

I think you meant rep(NA, 3).

  
    
#
On Sat, 11 May 2002 ripley@stats.ox.ac.uk wrote:

            
To amplify that, rep(NA, 3) gives a vector of *logical* NAs, just as
matrix(NA, 2, 2) gives a logical matrix.   There are five different
missing values in R, and `NA' happens to be mapped to the logical one
(unless coerced, implicitly or explicitly).

People normally want numerical missing values, for which use
rep(as.numeric(NA), 3).  Replace `numeric' by `integer', `complex' or
`character' for the other possibilities.