[R] display of character NA's in a dataframe in 1.5.0

David Kane <David Kane a296180 at mica.fmr.com
Tue Apr 30 21:13:39 CEST 2002


Thanks to Douglas Bates, Brian Ripley and Don MacQueen for taking the time to
answer my question. I think that Doug Bates puts it best when he writes:

>The difference in the display of character NA's is according to
>whether the quote option is on.  By default it is on for character
>vectors, so an NA is displayed as NA and the character string "NA" is
>displayed as "NA", and off for data frames, so an NA is displayed as
><NA> and the character string "NA" is displayed as NA.

So, in my example, we can see:

> c("x", NA, "y")
[1] "x" NA  "y"
> print(c("x", NA, "y"), quote = FALSE)
[1] x    <NA> y   
> data.frame(a = c("x", NA, "y"))
     a
1    x
2   <NA>
3    y
> print(data.frame(a = c("x", NA, "y")), quote = TRUE)
    a
1 "x"
2  NA
3 "y"

As best I can tell, this is not an "option," in the sense of something that the
user can set with options(). That is, unless you want to override the default
print methods, the display will be different for vectors and for
dataframes. There was also information about this in the NEWS file for 1.5.0.

Thanks to all,

Dave Kane
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list