David Brahm
2001-Oct-04 15:19 UTC
[Rd] Characters subsetted with NA (was: Several R vs S-Plus issues)
Hello, R-devel! I posted to R-help, and (inappropriately) to R-bugs, this R/S-Plus difference:> LETTERS[c(NA,2)] in S is c("","B"), but in R is c("NA","B")Kurt Hornik <Kurt.Hornik@ci.tuwien.ac.at> wrote:> I think we do not want to change this. ... > R> is.na(LETTERS[c(NA,2)])[1] TRUE FALSE> so we really have NA but it is printed as "NA" (and this might be > another case where <NA> would be better).This is merely a statement about is.na(), namely that it flags the string "NA". There is no distinction in R between the "NA" that arises from subsetting with a missing value, and the "NA" that represents Nabisco. Note: R> all.equal(LETTERS[c(NA,2)][1], substring("NABISCO",1,2)) [1] TRUE R thinks I am missing data when I trade Nabisco, in the Netherlands/Antilles, or through trader Neil Armstrong. In each case, "" would more likely indicate a missing value; there is no stock with that ticker, country with that symbol, or trader with those initials. I'd think it would be easy to make is.na() flag "" instead of "NA". However, I'm stuck at the definition: R> is.na .Primitive("is.na") so I don't know how to change it (I'm a lousy developer, you see). I propose again that we provide options(na.char="NA"), so users can make their own choice. Thanks for listening! -- David Brahm (brahm@alum.mit.edu) -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel 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-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Peter Dalgaard BSA
2001-Oct-04 15:45 UTC
[Rd] Characters subsetted with NA (was: Several R vs S-Plus issues)
David Brahm <a215020@agate.fmr.com> writes:> R> is.na > .Primitive("is.na") > so I don't know how to change it (I'm a lousy developer, you see). > > I propose again that we provide options(na.char="NA"), so users can make their > own choice. Thanks for listening!Other's have been on the warpath re. this issue lately (and it's been an annoyance for years - NorAdrenalin, Nitric Acid, etc.). It's not unlikely to find a solution for 1.4, but probably not the one you are proposing. Basically, we should have a *real* NA for string variables, distinct from the character string "NA" and propagating like any other NA's. Inserting a value to substitute for missing could be handled differently, e.g. via replace.na <- function(x,r){x[is.na(x)]<-r; x} -- O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk) FAX: (+45) 35327907 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel 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-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
David Brahm
2001-Oct-04 16:10 UTC
[Rd] Characters subsetted with NA (was: Several R vs S-Plus issues)
Peter Dalgaard <p.dalgaard@biostat.ku.dk> wrote:> Basically, we should have a *real* NA for string variables, distinct from > the character string "NA" and propagating like any other NA's.I could go for that. How would it appear when cat()ed or print()ed? -- David Brahm (brahm@alum.mit.edu) -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel 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-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._