[R] Call to glm inside a function

Spencer Graves spencer.graves at pdf.com
Mon Feb 17 19:45:03 CET 2003

	  Others know this subject much better than I do, and you should ignore 
these remarks if you get a more authoritative reply sooner, but in the 
interest of getting you an answer now, I'll expose my ignorance on this 
subject:  First, if you have access to a copy of Venables and Ripley, S 
Programming, I would read about "assign" there (and all other 
documentation you can find).

	  I'm guessing that "gml" probably uses "get" to find the weights and 
can't find them because it does not look in the frame of the calling 

	  To get around this, try an "assign" something like the following 
before your call to "glm":

	  assign("data", data)

   	  I'm not certain this will work, but I've had similar problems in 
S-Plus and worked around them using assign.

	  I don't have time to work an example now,  but if this does not fix 
your problem, you might experiment with the "assign" arguments until you 
find something that works.  I don't like being too bold with "assign", 
because I don't understand what it does, and it could be just a little 
dangerous -- like overwriting a library or something.

Best Wishes,
Spencer Graves

ZABALZA-MEZGHANI Isabelle wrote:
> Hello,
> I want to call glm inside a function. In the first lines of code I build the
> weights, the formula, ... and then I call glm with the following command:
>     glm(formularesp, data=data, family=familyresp,
> weights=eval(data$weights)
> My problem is that the fitting proccess is performed just like if
> weights=NULL, even if my weights are not equals to 1. I've performed some
> return() command before this glm call to check the value of each argument,
> and everything seems OK.
> Please, help me to understand why the code bypass my weighting instruction.
> Regards
> Isabelle
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> http://www.stat.math.ethz.ch/mailman/listinfo/r-help

More information about the R-help mailing list