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
Hi Hadley,
On 05/30/2014 07:06 AM, Hadley Wickham wrote:
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
There is at least one subtle consequence to keep in mind when doing
this. Of course, whatever choice you make, if the whatever() function
moves to a different package, this breaks your package.
However, if you explicitly import the function, your package will
break at load-time (which is
This isn't likely to make much difference in most cases, but calling a
function via :: can incur up to about twice the overhead on average
compared to calling an imported function
fun1
function ()
file_ext(text.txt)
environment: namespace:imptest
fun2
function ()
tools::file_ext(text.txt)
On Fri, May 30, 2014 at 6:55 PM, Hervé Pagès hpa...@fhcrc.org wrote:
[...]
There is at least one subtle consequence to keep in mind when doing
this. Of course, whatever choice you make, if the whatever() function
moves to a different package, this breaks your package.
However, if you
On 05/30/2014 10:00 AM, Hadley Wickham wrote:
There is at least one subtle consequence to keep in mind when doing
this. Of course, whatever choice you make, if the whatever() function
moves to a different package, this breaks your package.
However, if you explicitly import the function, your
Finally, now that the use of a NAMESPACE became mandatory (well, this
happened a few years ago), advocating systematic use of foo::whatever()
without explicitly importing the function sounds a little bit like an
heroic act of resistance ;-)
I don't think that's at all true - for most other
On Fri, May 30, 2014 at 9:08 PM, Hadley Wickham h.wick...@gmail.com wrote:
Finally, now that the use of a NAMESPACE became mandatory (well, this
happened a few years ago), advocating systematic use of foo::whatever()
without explicitly importing the function sounds a little bit like an
On Fri, May 30, 2014 at 9:17 PM, Gábor Csárdi csardi.ga...@gmail.com
wrote:
On Fri, May 30, 2014 at 9:08 PM, Hadley Wickham h.wick...@gmail.com
wrote:
Finally, now that the use of a NAMESPACE became mandatory (well, this
happened a few years ago), advocating systematic use of
Hi Gabe,
On 05/30/2014 11:34 AM, Gabriel Becker wrote:
This isn't likely to make much difference in most cases, but calling a
function via :: can incur up to about twice the overhead on average
compared to calling an imported function
fun1
function ()
file_ext(text.txt)
environment:
Using `::` does add some overhead - on the order of 5-10 microseconds
on my computer. Still, it would take 100,000 calls to add 0.5-1 second
of delay.
microbenchmark(
base::identity(1),
identity(1),
unit = us
)
# Unit: microseconds
# expr min lq median uqmax
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
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
13 matches
Mail list logo