s-news
[Top] [All Lists]

Re: NA's in string vector.

To: "'Prof Brian D Ripley'" <ripley@stats.ox.ac.uk>, "Vadim Kutsyy" <vkutsyy@cytokinetics.com>
Subject: Re: NA's in string vector.
From: "Gunter, Bert" <bert_gunter@merck.com>
Date: Fri, 07 Dec 2001 08:51:30 -0500
Cc: "S-News (E-mail)" <s-news@lists.biostat.wustl.edu>
All:

In fact, on p. 204 the Green book explicitly states: "string objects can
have missing values...; character vectors contain pointers, for which S does
not support the idea of NA."

Unfortunately, it used to, AFAIK, so explicit casts of character to string
-- x<-as(x,'string') -- may be necessary to prevent old code from breaking,
I would guess. 

Finally, in SPlus 6 for Windows, anyway, the Help files (or paper manuals)
are no help on this: there's no documentation at all for is.na<- and the
entry for "string" says:

"Function string is not supported in this version. Its use is discouraged. "

From which most of us would infer that we should NOT do the cast or that it
may not work.

So this seems like a fine mess to me. As always, I welcome further
enlightenment.

Cheers,
Bert Gunter
Biometrics Research RY 70-38
Merck & Company
P.O. Box 2000
Rahway, NJ 07065-0900
Phone: (732) 594-7765
mailto: bert_gunter@merck.com

"The business of the statistician is to catalyze the scientific learning
process."      -- George E.P. Box




-----Original Message-----
From: Prof Brian D Ripley [mailto:ripley@stats.ox.ac.uk]
Sent: Friday, December 07, 2001 1:43 AM
To: Vadim Kutsyy
Cc: S-News (E-mail)
Subject: Re: [S] NA's in string vector.


On Thu, 6 Dec 2001, Vadim Kutsyy wrote:

> Is there a way to define NA's in string vector?
>
> > a<-c("a",NA,"b")
> > is.na(a)
> [1] F F F
> > a
> [1] "a"  "NA" "b"
> > a[2]<-NA
> > is.na(a)
> [1] F F F
>
> Splus converge all NA's to "NA", which make problem in data.frames.

Actually, that's a character vector, and for once the distinction matters.
Under S4, `string' is a separate class, and the way I know to do this is to
use the `string' class and is.na<-.  See the Green Book.

-- 
Brian D. Ripley,                  ripley@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



<Prev in Thread] Current Thread [Next in Thread>