From hpages at fhcrc.org  Tue Feb 26 23:47:51 2013
From: hpages at fhcrc.org (=?windows-1252?Q?Herv=E9_Pag=E8s?=)
Date: Tue, 26 Feb 2013 14:47:51 -0800
Subject: [Rd] Recommended way to call/import functions from a Suggested
 package
In-Reply-To: <CABdHhvGp93siXObHgCiFAi7zyee=REy22XM5O05X75=fUaf0VQ@mail.gmail.com>
References: <FD2C7845-F6AD-4AA1-91C1-8CB14F43AA7D@stat.ubc.ca>
	<CABdHhvHkJkyzKODdDKKt+fmCeUAXJC7L24vXLuLPWmRYsYZtkQ@mail.gmail.com>
	<FDF2030A-2A91-4A40-B09F-C4DD78682A62@r-project.org>
	<CABdHhvHx1H09Qbx6mGBZUkB-yyta5nNv-cg=JgbS+0Js-iN7Yw@mail.gmail.com>
	<4F6FBC64-4EAE-43E2-B041-B54663CDF950@stat.ubc.ca>
	<CABdHhvEwU9mgnnL1=iHur-JMFwOOPkkv8P164g=uVuaf8xWajQ@mail.gmail.com>
	<512BE76D.8090107@fhcrc.org>
	<CABdHhvGp93siXObHgCiFAi7zyee=REy22XM5O05X75=fUaf0VQ@mail.gmail.com>
Message-ID: <512D3B97.1040304@fhcrc.org>

Hi,

So MASS::huber(1:10) seems to do the job i.e. (1) loads the MASS
package (if it's installed), (2) does not pollute the search path,
(3) no 'R CMD check' warning if MASS is listed in Suggests,
and (4) descent error message if MASS is not installed:

   > MASS::huber(1:10)
   Error in loadNamespace(name) : there is no package called ?MASS?

So is this recommendable or are there good reasons for stating in
the manual that "this approach is usually not recommended"? (In which
case it would be good to know what the recommended way is.)

Thanks,
H.


On 02/25/2013 02:56 PM, Hadley Wickham wrote:
>> loadNamespaces loads but does not attach the package. Suggests: is enough to
>> quieten the warning with
>>
>> ~/tmp$ R --version
>> R Under development (unstable) (2013-02-21 r62017) -- "Unsuffered
>> Consequences"
>>
>> This is consistent with RShowDoc("R-exts") section 1.1.1
>>
>>    Namespaces accessed by the ?::? and ?:::? operators must be listed here,
>> or in ?Suggests? or ?Enhances? (see below).
>
> I guess that's changed since I last tried it.  (My reproducible
> example forgot to include MASS in the Suggests :/ )
>
> Thanks!
>
> Hadley
>

-- 
Herv? Pag?s

Program in Computational Biology
Division of Public Health Sciences
Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N, M1-B514
P.O. Box 19024
Seattle, WA 98109-1024

E-mail: hpages at fhcrc.org
Phone:  (206) 667-5791
Fax:    (206) 667-1319



[Rd] Recommended way to call/import functions from a Suggested package
=?windows-1252?Q?Herv=E9_Pag=E8s?=