[R] restrictions for attribute access <Watchdog: Virus checked>

Benjamin Polak benjamin.polak at unisg.ch
Wed Apr 2 15:18:02 CEST 2008


Ah, that was it! I added "importFrom(Matrix, summary)" to my NAMESPACE 
file, and now it works.

Thanks
Ben


On Wednesday, 2. April 2008 14:59, Prof Brian Ripley wrote:
> On Wed, 2 Apr 2008, Henrique Dallazuanna wrote:
> > Work's for me:
> >
> > summary(lmer(Reaction ~ Days + (Days|Subject),
> > sleepstudy))@AICtab
>
> I think the issue is that in his package he is not seeing the
> summary S4 generic from Matrix (which is the one lme4 sets methods
> on).  The package needs to import summary() from Matrix (and not
> lme4).
>
> Try
>
> > library(lme4)
>
> ...
>
> > find("summary")
>
> [1] "package:Matrix" "package:base"
>
> and remember that base namespace comes before the search path in a
> package with a NAMESPACE.
>
> Things get even more complicated if other S4-using packages are
> involved.
>
> > On Wed, Apr 2, 2008 at 9:36 AM, Benjamin Polak
> > <benjamin.polak at unisg.ch>
> >
> > wrote:
> >> Thanks, but it doesn't work, I get the error message:
> >>
> >> 'no slot of name "AICtab" for this object of class "table"'
> >>
> >> On Wednesday, 2. April 2008 13:34, Henrique Dallazuanna wrote:
> >>> You've tried:
> >>>
> >>> tab <- smry at AICtab
> >>>
> >>> ?
> >>>
> >>> On Wed, Apr 2, 2008 at 7:59 AM, Benjamin Polak
> >>
> >> <benjamin.polak at unisg.ch> wrote:
> >>>> Hello everybody,
> >>>>
> >>>>  I have a problem with accessing class attributes. I think it
> >>>> might be due to namespace access restrictions or something
> >>>> similar, but I'm unable to figure it out, maybe someone knows
> >>>> the trick how to do it ...
> >>>>
> >>>>  I'm trying to extract some information from the summary
> >>>> object for a model fitted using the lmer function from the
> >>>> lme4 package:
> >>>>
> >>>>   smry <- summary(lmer(foo ~ bar ...))
> >>>>   tab <- attr(smry, "AICtab")
> >>>>   tab$AIC
> >>>>
> >>>>  When I run this code as a regular R script everything works
> >>>> fine, tab$AIC has the desired value. But when I try to run
> >>>> this code from within a package I wrote, tab$AIC is NULL.
> >>>>
> >>>>  I've tried adding "import(lme4)", "importClassesFrom(lme4)"
> >>>>  and "importMethodsFrom(lme4)" into the NAMESPACE file of my
> >>>> package, but it didn't help, tab$AIC is still NULL.
> >>>>
> >>>>  Thanks for any kind of hint!
> >>>>
> >>>>  Best Regards,
> >>>>  Ben



More information about the R-help mailing list