I upgraded R-base 1.2.0 today, and then I intended to give a finishing touch to some R functions I should send out today. To my surprise, they failed in R 1.2 although they still worked fine in R 1.0.1 (I checked in another machine). The error message I got was like this:> optci(trar.g, water)Error in unique(c("AsIs", class(x))) : Object "x" not found The function call was> optci <- function (model, x, confidence = 0.95)where "model" is a glm object and "x" is a variable, in this case "water" (not a very unique name, though). It seems that "x=water" is passed OK as a variable, but the error comes when I try pass "x" to another function within "optci". This function calls still another function, and, now it comes, this calls update.formula. It seems that the error comes after this update. I see that the update.formula has changed between 1.0.1 and 1.2.0 and update is defines explicitly the environment as the environment of the original glm which in this case is <environment: R_GlobalEnv>, and I try to update the formula with a variable defined within local scope. Is this a likely explanation, and if so, is there a road ahead or should I just give up? At least I cannot trace this problem any longer, since update.formula is the last R code I see. It then vanishes into update which is non-transparent to me. update.formula seems to work OK, but the error message seems to come from update. Sorry for the trouble, and thankful for any help. cheers, jari oksanen -- Jari Oksanen - Dept Ecol Env Sci, Univ Helsinki, 15140 Lahti Ph. +358 3 89220312, Fax -- 89220289, Mobile +358 40 5136529 jari.oksanen at helsinki.fi http://www.helsinki.fi/~jhoksane -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help 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-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Indeed there have been some changes to the way in which formulas
resolve the symbols they contain. We hope that overall it will be for
the better but there are some situations where things need to change.
First let me explain why we changed things.
Suppose that I have the following:
x<- somedata
y<- someotherdata
form<-y~x
here I have a clear idea that the y and x in my formula are
the y and x I have defined
but under the old system there was no way to ensure that
foo<-function(form) {
x <- 1
y <-2
model.frame(form)
}
a call to foo in the old system would cause me to pick up
the local values of x and y -- 1 and 2, not my original
data.
you are in the situation, I think, where you want the local x and y
to do that I would change the function foo to:
foo<-function(form) {
x <- 1
y <-2
model.frame(form, data=environment())
}
Which asks form to first look in the environment or data frame
specified by data argument. As the help file says, the second place to
look is the environment associated with the formula (lexical scope,
sort of). We no longer search the top-level environment (or any other
environment) for unresolved symbols.
The goal is to ensure more robust modeling although I'm sure the
impact on some will be a bit of frustration.
You didn't provide enough code for me to tell you how to fix your
particular problem, but if these hints aren't enough please send me a
more complete version of your code and I'll give you some concrete
suggestions.
Robert
--
+---------------------------------------------------------------------------+
| Robert Gentleman phone : (617) 632-5250 |
| Associate Professor fax: (617) 632-2444 |
| Department of Biostatistics office: not yet |
| Harvard School of Public Health email: rgentlem at jimmy.dfci.harvard.edu |
+---------------------------------------------------------------------------+
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help 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-help-request at
stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._