R-alpha: Playing the tag game

Peter Dalgaard BSA p.dalgaard@kubism.ku.dk
20 Apr 1997 18:40:06 +0200


Here are a handful of oddities in pre0.50-7 (at some risk of reprisals
from people waiting for the real 0.50...):

I was mucking about trying to figure out how to know which tags has
been used in a function call, and some weird stuff happened.

----------
A call with tagged arguments is something like a list, the tags
can be used to access elements, but the names attribute is absent,
until the call is coerced to a list. (Attempting to set the names()
causes evaluation. Changing "list" to "blipblop" causes an 'Error:
couldn't find function "blipblop"' at that point.)

> j<-substitute(list(a=1,b=2))
> j
list(a = 1, b = 2)
> j$b
[1] 2
> names(j)
NULL
> names(j)<-NULL
> j
[[1]]
[1] 1

[[2]]
[1] 2
-----------
This one is plainly a bug. Meaningless, but...

[Previously saved workspace restored]

> j<-as.call(list(a=1,b=2))
> j
Segmentation fault (core dumped)
------------
Strange... as.call should return its argument if is.call is true?

> j<-substitute(list(a=1,b=2))
> j
list(a = 1, b = 2)
> as.call(j)
Error in as.call(j) : invalid argument list
> is.call(j)
[1] TRUE

------------
Ok, the right solution seems to be names(as.list(j)), but then we run
into some other fun with NA's... Shouldn't the real NA print without
quotes?

> ch[1]<-paste("N","A",sep="") 
> is.na(ch)
[1] FALSE FALSE FALSE
> ch
[1] "NA" "a"  "b" 
> ch[1]=="NA"
[1] TRUE
> ch[1]<-"NA"                 
> is.na(ch)
[1]  TRUE FALSE FALSE
> 

-- 
   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
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-