[Rd] declaring package dependencies

Gray Calhoun gray at clhn.co
Fri Sep 13 19:52:37 CEST 2013


John Fox: (12:15PM on Fri, Sep 13)
[...cut...]
>I think that most users --
>as opposed to R developers -- will find the package::function( ... ) syntax
>in examples not so much ugly as cryptic. I think that we have ample recent
>evidence on this list that even developers (I don't exempt myself) are
>confused by namespace issues. On balance, I prefer
>
>	if (require(MASS)) {
>		loglm( ...)
>	}
>
>which tells the user that it's necessary to load MASS before using loglm().
>
>It would be nice if examples ran in a "sandbox," so that an example could
>read something like
>
>	library(MASS)
>	loglm( ... )
>	. . .
>
>without affecting the path in the current session, and fail gracefully if
>the MASS package weren't available (unlikely, of course, in the case of
>MASS, but not more generally).

Does assigning

     loglm <- MASS::loglm
     loglm( ... )

not work in examples anymore? (with MASS listed under 'Suggests'.)
That seems like it could address both concerns, but it would mask
loglm if it were already defined.

-- 
Gray Calhoun, Assistant Professor of Economics at Iowa State 
http://gray.clhn.co // (515) 294-6271 // 467 Heady Hall



More information about the R-devel mailing list