From jari.oksanen at oulu.fi  Wed Aug 22 19:53:39 2007
From: jari.oksanen at oulu.fi (Jari Oksanen)
Date: Wed, 22 Aug 2007 20:53:39 +0300
Subject: [Rd] paste() with NAs ..  change worth persuing?
In-Reply-To: <46CC6F7C.2010600@stats.uwo.ca>
References: <18124.23379.575814.316093@stat.math.ethz.ch>
	<46CC6F7C.2010600@stats.uwo.ca>
Message-ID: <2d3b61b809045fef4ca309796b8ac642@oulu.fi>


On 22 Aug 2007, at 20:16, Duncan Murdoch wrote:

> On 8/22/2007 11:50 AM, Martin Maechler wrote:
>> Consider this example code
>>
>>  c1 <- letters[1:7]; c2 <- LETTERS[1:7]
>>  c1[2] <- c2[3:4] <- NA
>>  rbind(c1,c2)
>>
>>   ##   [,1] [,2] [,3] [,4] [,5] [,6] [,7]
>>   ## c1 "a"  NA   "c"  "d"  "e"  "f"  "g"
>>   ## c2 "A"  "B"  NA   NA   "E"  "F"  "G"
>>
>>   paste(c1,c2)
>>
>>   ## -> [1] "a A"  "NA B" "c NA" "d NA" "e E"  "f F"  "g G"
>>
>> where a more logical result would have entries 2:4 equal to
>>       NA
>> i.e.,  as.character(NA)
>> aka    NA_character_
>>
>> Is this worth persuing, or does anyone see why not?
>
> 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().

cheers, jazza
--
Jari Oksanen, Oulu, Finland



[Rd] paste() with NAs .. change worth persuing?
Jari Oksanen