s-news
[Top] [All Lists]

Re: setting missing value in a character matrix in S-Plus

To: array chip <arrayprofile@yahoo.com>
Subject: Re: setting missing value in a character matrix in S-Plus
From: Prof Brian Ripley <ripley@stats.ox.ac.uk>
Date: Thu, 17 Feb 2005 22:19:02 +0000 (GMT)
Cc: s-news@lists.biostat.wustl.edu
In-reply-to: <20050217220942.65187.qmail@web40824.mail.yahoo.com>
References: <20050217220942.65187.qmail@web40824.mail.yahoo.com>
R has missing elements in character vectors: S does not.

On Thu, 17 Feb 2005, array chip wrote:

how can I set some elements in a character matrix as
missing values (NAs)? for example:

x<-matrix(rep('q',30),nrow=5)
x[x=='q']<-NA

will give me a character matrix with all elements
being "NA", but not missing values NA. The above codes
work prefectly well in R, but do not give me the right
answerin S-Plus. However, the codes work well if the
input matrix x is a numeric matrix.

--
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 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

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