Thanks for confirming my suspicions! And yes, I (clearly) don't understand
how namespaces work in R. I've only been able to find bits and pieces on the
web (and the Intro to R). Most of these have been confused and don't tell
you much. The Intro to R states: "Namespaces prevent the user's definition
from taking precedence, and breaking every function..."

Are functions occurring in namespaces essentially immovable/un-alterable
objects? (i.e. is a namespace the "No Trespassing" sign of the R world?)

Is there a good reference for getting more insight to namespaces and how
they work or how to work with them?  (preferably online...)

Best,
Ben

2010/8/1 Prof Brian Ripley <rip...@stats.ox.ac.uk>

> On Sun, 1 Aug 2010, Benjamin Ridenhour wrote:
>
>  Hello all,
>> I'm sure I'm missing something simple here, but I can't figure out how to
>> modify the glm.fit() function and then get R to use it (sort of). I'm
>> doing
>> something along the lines of:
>>
>> glm.fit<-edit(glm.fit) # add something trivial to the top of the glm.fit
>> function like: print("Hello world!")
>>
>> #now have a modified glm.fit in position 1/.GlobalEnv
>>
>> x<-rnorm(20)
>> y<-rnomr(20)
>>
>> glm(y~x)  # I don't get the trivial bit of glm.fit back (i.e. "Hello
>> world!"
>> doesn't print)
>>
>> #but
>>
>> glm(y~x,method=glm.fit) # works! I get "Hello world!"
>>
>> My understanding is that glm() should call glm.fit() by default but it
>> seems
>> to be calling the glm.fit() in "package:stats" and not ".GlobalEnv". Why
>> isn't the function in ".GlobalEnv" superseding the version in
>> "package:stats"?
>>
>
> Because that is the way scoping works in R -- you need to understad the
> concept of name spaces.
>
> This is not the way to do what you seem to want: rename your fitter
> function and use
>
>  method: the method to be used in fitting the model.  The default
>          method ‘"glm.fit"’ uses iteratively reweighted least squares
>          (IWLS), whereas ‘"model.frame"’ which returns the model frame
>          and does no fitting.  User-supplied fitting functions can be
>          supplied either as a function or a character string naming a
>          function, with a function which takes the same arguments as
>          ‘glm.fit’.
>
> to specify it.
>
>
>> Thanks,
>> Ben
>>
>
> --
> Brian D. Ripley,                  rip...@stats.ox.ac.uk
> Professor of Applied Statistics,  
> http://www.stats.ox.ac.uk/~ripley/<http://www.stats.ox.ac.uk/%7Eripley/>
> University of Oxford,             Tel:  +44 1865 272861 (self)
> 1 South Parks Road,                     +44 1865 272866 (PA)
> Oxford OX1 3TG, UK                Fax:  +44 1865 272595

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to