[R] packagename:::functionname vs. importFrom

Bill.Venables at csiro.au Bill.Venables at csiro.au
Tue Jan 4 06:28:20 CET 2011


If you use ::: to access non-exported functions, as Frank confesses he does, then you can't complain if in the next release of the package involved the non-exported objects are missing and things are being done another way entirely.  That's the deal.

On the other hand, sometimes package authors do not envisage all the ways their package will be used and neglecting to export some object is mostly because the author simply did not anticipate that anyone would ever need to use it. But sometimes they do.  A common case is when you need to do some operations very efficiently and there are simplifications in the input of which you can take advantage to cut down on the overheads.  In that case you usually need the cut-down (non-exported) workhorse rather than the (exported) show-pony front end.

The documentation suggests that if you ever need to use ::: perhaps you should be contacting the package maintainer to have the article in question exported.  This makes a lot of sense, but it can also creates quite a bit of work for the maintainers, too, if they agree to do it.

It's a very grey area, in my experience.

Bill Venables. 

-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of Hadley Wickham
Sent: Tuesday, 4 January 2011 3:06 PM
To: Frank Harrell
Cc: r-help at r-project.org
Subject: Re: [R] packagename:::functionname vs. importFrom

> Correct.  I'm doing this because of non-exported functions in other packages,
> so I need :::

But you really really shouldn't be doing that.  Is there a reason that
the package authors won't export the functions?

> I'd still appreciate any insight about whether importFrom in NAMESPACE
> defers package loading so that if the package is not actually used (and is
> not installed) there will be no problem.

Imported packages need to be installed - but it's the import vs.
suggests vs. depends statement in DESCRIPTION that controls this
behaviour, not the namespace.

Hadley


-- 
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University
http://had.co.nz/

______________________________________________
R-help at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list