[Rd] as.character(list(NA))

2018-01-20 Thread Patrick Perry

As of R Under development (unstable) (2018-01-19 r74138):

> as.character(list(NA))
[1] "NA"

> is.na(as.character(list(NA)))
[1] FALSE

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] as.character(list(NA))

2018-01-20 Thread Dirk Eddelbuettel

On 20 January 2018 at 10:43, Patrick Perry wrote:
| As of R Under development (unstable) (2018-01-19 r74138):
| 
|  > as.character(list(NA))
| [1] "NA"
| 
|  > is.na(as.character(list(NA)))
| [1] FALSE

Are you aware that this is the same in R-release, and might be "on purpose" ?

R> R.Version()$version.string
[1] "R version 3.4.3 (2017-11-30)"
R> as.character(list(NA))
[1] "NA"
R> is.na(as.character(list(NA)))
[1] FALSE
R> 

It is after all you who forces the as.character() and I don't think anybody
claims that to be a lossless operation from logical.  To wit:

R> is.na(list(NA))
[1] TRUE
R> 

Dirk

-- 
http://dirk.eddelbuettel.com | @eddelbuettel | e...@debian.org

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] as.character(list(NA))

2018-01-20 Thread William Dunlap via R-devel
I believe that for a list as.character() applies deparse()  to each element
of the list.  deparse() does not preserve NA-ness, as it is intended to
make text that the parser can read.

> str(as.character(list(Na=NA, LglVec=c(TRUE,NA),
Function=function(x){x+1})))
 chr [1:3] "NA" "c(TRUE, NA)" "function (x) \n{\nx + 1\n}"


Bill Dunlap
TIBCO Software
wdunlap tibco.com

On Sat, Jan 20, 2018 at 7:43 AM, Patrick Perry  wrote:

> As of R Under development (unstable) (2018-01-19 r74138):
>
> > as.character(list(NA))
> [1] "NA"
>
> > is.na(as.character(list(NA)))
> [1] FALSE
>
> __
> R-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

[[alternative HTML version deleted]]

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel