as.name is not idempotent

Peter Dalgaard BSA p.dalgaard@biostat.ku.dk
30 Dec 1997 13:05:13 +0100


Douglas Bates <bates@stat.wisc.edu> writes:

> At least I think the word I want "idempotent" - it has been a long
> debugging session and my brain is fried so I am not sure.

I.: f(f(x)) == f(x) all x, so it's exactly the right term...

> What I mean is that as.name applied to a name gives an error.
>  > as.name("foo")
>  foo
>  > as.name(as.name("foo"))
>  Error in as.name(x) : character argument required
> 
> It might help if it were a bit more flexible about the arguments it
> accepts.

This is plainly a bug. If it bothers you badly, insert 

if(is.name(x)) return(x)

at the start of as.name.

In general, it should invariably hold that

is.xx(x) == TRUE implies as.xx(x) == x
and
is.xx(as.xx(x)) == TRUE unless as.xx fails

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk)             FAX: (+45) 35327907

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._