R-alpha: incompatibilities

Thomas Lumley (thomas@biostat.washington.edu)
Tue, 10 Sep 1996 11:45:28 -0700 (PDT)


Date: Tue, 10 Sep 1996 11:45:28 -0700 (PDT)
From: Thomas Lumley <thomas@biostat.washington.edu>
To: r-testers@stat.math.ethz.ch
Subject: R-alpha: incompatibilities
In-Reply-To: <m0v0UBU-0000TpC@franz.stat.wisc.edu>

Three more incompatibilities, all relatively minor.

1. When model.frame() is called with a formula containing literal arguments, 
the column names are X1,X2 etc, rather than deparse(substitute()) applied 
to the argument: eg

S> dimnames(model.frame(y~rep(1:2,25)))[[2]]
[1] "y"            "rep(1:2, 25)"
R> dimnames(model.frame(y~rep(1:2,25)))[[2]]
[1] "y"  "X2"


2. parse(text=) returns a one-element list  in R and an 
expression in S. Fortunately parse()[[1]] works in either S or R.
R> parse(text="1+1")
[[1]]
1 + 1
S>  parse(text="1+1")
expression(1 + 1)
S> parse(text="1+1")[[1]]
1 + 1



3. eval() uses a different default environment in R than in S. It seems as
though eval(,envir=environment(NULL)) does what eval() does in S (at least
inside a function). 

a<-function(i) { j<-"i"; eval(parse(text=j)[[1]])}
R> a(10)
Error: Object "i" not found

S> a(10)
[1] 10

R> a<-function(i) { j<-"i"; eval(parse(text=j)[[1]],envir=environment(NULL))}
R> a(10)      
[1] 10


The first two of these should be easily fixed, I'm not sure about the 
last.  These all arose in trying to port Therneau's survival4 library 
(which is *much* better than survival3), in what is perhaps an 
unnecessarily clever section of code to construct group names for the 
logrank test.


thomas lumley
Biostatistics
U Washington

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
r-testers mailing list -- To (un)subscribe, send
subscribe	or	unsubscribe
(in the "body", not the subject !)  To: r-testers-request@stat.math.ethz.ch
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-