Hi Ronald,
On 05/28/2014 01:46 PM, Ronald Barry wrote:> Greetings,
> When using a 'foreign' function (from another package, say
function
> 'whatever' from package 'foo'), you can of course just
require the package
> and then just have
>
> whatever(...)
>
> in your code. However, I would like to use the
>
> foo::whatever(...)
>
> form instead, just for documentation purposes (easier to see what function
> comes from what package). Is there a cost to doing this? Is it considered
> good or bad style? Thanks.
Even more important than choosing between whatever(...)
or foo::whatever(...), you should import that function
from the foo package by putting
importFrom(foo, whatever)
or
import(foo)
in your NAMESPACE file.
The 1st form also kind of document what function comes from what
package.
Note that you'll also need to have foo in the Depends or Imports field
of your DESCRIPTION file. Which field is appropriate depends on whether
or not you want foo to show up in the user's search path when s/he loads
your package with 'library(yourpackage)'.
Cheers,
H.
>
> Ron Barry
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>
--
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