Re: [Rd] paste() with NAs .. change worth persuing?

From: Duncan Murdoch <murdoch_at_stats.uwo.ca>
Date: Wed, 22 Aug 2007 13:16:44 -0400

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...)

Duncan Murdoch



R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Wed 22 Aug 2007 - 17:36:44 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 23 Aug 2007 - 13:39:06 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.