Skip to content
Prev 74756 / 398502 Next

Read from data frame, and not from global environment

I don't think that is the best way to do what I guess you intended. Try 
something like

test <- function(formula,  data , weights)
{
     Call <- match.call()
     Call[[1]] <- as.name("glm")
     Call$family <- quote(poisson)
     glm1 <- eval.parent(Call)
     ....
}

which is probably giving the scoping that you want.

You could do what you ask for at 1) by something like

     wname <- deparse(substitute(w))
     w <- if(wname %in% names(data)) data[[wname]] else get(wname, .GlobalEnv)

and for 2) by replacing .GlobalEnv by an expression constructed by calls 
to environment() (I don't know exactly what you intended here).
On Tue, 2 Aug 2005, Jochen Einbeck wrote:

            
That contradicts 1)!