From murdoch.duncan at gmail.com  Thu Sep 12 19:37:29 2013
From: murdoch.duncan at gmail.com (Duncan Murdoch)
Date: Thu, 12 Sep 2013 13:37:29 -0400
Subject: [Rd] declaring package dependencies
In-Reply-To: <5231C3E3.3050007@yorku.ca>
References: <5231C3E3.3050007@yorku.ca>
Message-ID: <5231FBD9.6050802@gmail.com>

On 12/09/2013 9:38 AM, Michael Friendly wrote:
> I received the following email note re: the vcdExtra package
>
> > A vcd update has shown that packages TIMP and vcdExtra are not
> > declaring their dependence on colorspace/MASS: see
> >
> > http://cran.r-project.org/web/checks/check_results_vcdExtra.html
> But, I can't see what to do to avoid this, nor understand what has
> changed in R devel.
>
> Sure enough, CRAN now reports errors in examples using MASS::loglm(),
> using R Under development (unstable) (2013-09-11 r63906)
>
>   > Caesar.mod0 <- loglm(~Infection + (Risk*Antibiotics*Planned),
> data=Caesar)
> Error: could not find function "loglm"

I think this one would be fine if you had library(MASS) or require(MASS) 
or (probably best) used MASS::loglm explicitly.  It may be that in the 
past some other package put MASS on the search list, and that's why it 
worked before.

The distinction is between "loading" and "attaching" a package. Loading 
it (which would be done if you had MASS::loglm, or imported it) 
guarantees that the package is initialized and in memory, but doesn't 
make it visible to the user without the explicit MASS:: prefix.  
Attaching it first loads it, then modifies the user's search list so the 
user can see it.

Loading is less intrusive, so it's preferred over attaching.  Both 
library() and require() would attach it.

Duncan Murdoch
>
> In DESCRIPTION I have
> Depends: R (>= 2.10), vcd, gnm (>= 1.0.3)
> Suggests:
> ca,gmodels,Fahrmeir,effects,VGAM,plyr,rgl,lmtest,MASS,nnet,ggplot2,Sleuth2,car
>
> and the vcd DESCRIPTION has
>
> Depends: R (>= 2.4.0), grid, stats
> Suggests: KernSmooth, mvtnorm, kernlab, HSAUR, coin
> Imports: utils, MASS, grDevices, colorspace
>
> so, in an R 3.0.0 console, library(vcdExtra) loads vcd and its dependencies:
>
>   > library(vcdExtra)
> Loading required package: vcd
> Loading required package: MASS
> Loading required package: grid
> Loading required package: colorspace
> Loading required package: gnm
> Warning messages:
> 1: package ?vcd? was built under R version 3.0.1
> 2: package ?MASS? was built under R version 3.0.1
>   >
>
> Note: these CRAN errors do not occur on R-Forge, using R version 3.0.1
> Patched (2013-08-21 r63645)
> and the latest devel version (0.5-11) of vcdExtra.
>
> -Michael
>



[Rd] declaring package dependencies
Duncan Murdoch