Dear list,
The help page for library/require contains the following paragraph in
the section "Packages that require other packages":
The source code for a package that requires one or more other
packages should have a call to 'require', preferably near the
beginning of the source, and of course before any code that uses
functions, classes or methods from the other package.
Now, I'm being very dense today, but I don't know where to put such a
call to require.
My package has added methods for a generic function supplied by another
package. I have listed this package in the Depends field in my
DESCRIPTION.
What do I need to do to have the package that my package depends on be
attached when I call library or require to attach my package?
Apologies for being dense...
Thanks,
G
--
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
Gavin Simpson [T] +44 (0)20 7679 5522
ENSIS Research Fellow [F] +44 (0)20 7679 7565
ENSIS Ltd. & ECRC [E] gavin.simpsonATNOSPAMucl.ac.uk
UCL Department of Geography [W] http://www.ucl.ac.uk/~ucfagls/cv/
26 Bedford Way [W] http://www.ucl.ac.uk/~ucfagls/
London. WC1H 0AP.
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
On 11/9/2005 11:50 AM, Gavin Simpson wrote:> Dear list, > > The help page for library/require contains the following paragraph in > the section "Packages that require other packages": > > The source code for a package that requires one or more other > packages should have a call to 'require', preferably near the > beginning of the source, and of course before any code that uses > functions, classes or methods from the other package. > > Now, I'm being very dense today, but I don't know where to put such a > call to require. > > My package has added methods for a generic function supplied by another > package. I have listed this package in the Depends field in my > DESCRIPTION. > > What do I need to do to have the package that my package depends on be > attached when I call library or require to attach my package? > > Apologies for being dense...You can either put a call to require() in the function that needs it (which would be the best solution if that function is relatively rarely used), or in the startup code (in .First.lib, .onLoad, or .onAttach: see the manual for the differences) if you make extensive use of the other package. Duncan Murdoch
If I'm not mistaken, when you put the other package in the "Depends:" field of DESCRIPTION, the other package will be loaded first, before your package is loaded. So you shouldn't have to put require/library anywhere else. -roger Gavin Simpson wrote:> Dear list, > > The help page for library/require contains the following paragraph in > the section "Packages that require other packages": > > The source code for a package that requires one or more other > packages should have a call to 'require', preferably near the > beginning of the source, and of course before any code that uses > functions, classes or methods from the other package. > > Now, I'm being very dense today, but I don't know where to put such a > call to require. > > My package has added methods for a generic function supplied by another > package. I have listed this package in the Depends field in my > DESCRIPTION. > > What do I need to do to have the package that my package depends on be > attached when I call library or require to attach my package? > > Apologies for being dense... > > Thanks, > > G