[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 16:47:12 CEST 2002
I understand that NA's in character vectors are displayed differently than NA's
in factor vectors.
> c("x", NA, "y")
 "x" NA "y"
> as.factor(c("x", NA, "y"))
 x <NA> y
Levels: x y
That seems sensible enough. But shouldn't I see the same behavior in a dataframe?
> test <- data.frame(a = c("x", NA, "y"))
This behavior is correct since R coerces `a' to be a factor as it constructs
the test dataframe. But consider what happens when I force `a' to be character:
> test$a <- as.character(test$a)
The display is the same. I would have expected it to be something like:
If this is a bug, please let me know and I would be happy to submit it as
such. But, I suspect that it is more likely that there is something that I
don't fully understand about NA's and dataframes.
system sparc, solaris2.6
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