From savicky at cs.cas.cz  Thu Aug 23 15:49:32 2007
From: savicky at cs.cas.cz (Petr Savicky)
Date: Thu, 23 Aug 2007 15:49:32 +0200
Subject: [Rd] paste() with NAs ..  change worth persuing?
In-Reply-To: <2d3b61b809045fef4ca309796b8ac642@oulu.fi>
References: <18124.23379.575814.316093@stat.math.ethz.ch>
	<46CC6F7C.2010600@stats.uwo.ca>
	<2d3b61b809045fef4ca309796b8ac642@oulu.fi>
Message-ID: <20070823134932.GA28021@cs.cas.cz>

On Wed, Aug 22, 2007 at 08:53:39PM +0300, Jari Oksanen wrote:
> 
> On 22 Aug 2007, at 20:16, Duncan Murdoch wrote:
> > A fairly common use of paste is to put together reports for human
> > consumption.  Currently we have
> >
> >> p <- as.character(NA)
> >> paste("the value of p is", p)
> > [1] "the value of p is NA"
> >
> > which looks reasonable. Would this become
> >
> >> p <- as.character(NA)
> >> paste("the value of p is", p)
> > [1] NA
> >
> > under your proposal?  (In a quick search I was unable to find a real
> > example where this would happen, but it would worry me...)
> 
> At least stop() seems to include such a case:
> 
>   message <- paste(args, collapse = "")
> 
> and we may expect there are NAs sometimes in stop().

The examples show, that changing the behavior of paste in general
may not be appropriate. On the other hand, if we concatenate
character vectors, which are part of data, then is.na(paste(...,NA,...))
makes sense. Character vectors in data are usually represented
by factors. On the other hand, factors are not typical in cases,
where paste is used to produce a readable message. Hence, it
could be possible to have is.na(u[i]) for those i, for which
some of the vectors v1, ..., vn in
  u <- paste(v1,....,vn)
is a factor and has NA at i-th position.

Petr Savicky.



[Rd] paste() with NAs .. change worth persuing?
Petr Savicky