Dependencies: What does your package need? package::function()

52 views
Skip to first unread message

Ayala Allon

unread,
Jul 5, 2015, 8:33:16 AM7/5/15
to rdev...@googlegroups.com
Hey all,

I apologize in advance if this is not the right forum for my question (let me know if you think I should publish this elsewhere). I'm reading the part on Dependencies: What does your package need? in Hadley's book on R packages. It says there that if I add a package dependency using import it does not mean that it will be attached along with your package, and that the best practice is to explicitly refer to external functions using the syntax package::function(). I know my question is silly but I don't understand the  package::function() part. Can someone please provide me an example of how to implement this in a code? 

Any help will be greatly appreciated,

Ayala


Gábor Csárdi

unread,
Jul 5, 2015, 9:30:13 AM7/5/15
to Ayala Allon, rdev...@googlegroups.com
If you want to use the GET function from the httr package, then you can refer to it as httr::GET(...).
And of course you need to put httr in Imports in the DESCRIPTION file.

Gabor

--
You received this message because you are subscribed to the Google Groups "devtools" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rdevtools+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ayala Allon

unread,
Jul 5, 2015, 10:49:15 AM7/5/15
to Gábor Csárdi, rdev...@googlegroups.com
Thank you Gabor.
I have one more question concerning this issue. if I do  what you explained (and of course the put the package name in Imports in the DESCRIPTION file), it means that when one uses my package the dependencies will also be installed if he doesn't have them already and package::function() will exact the functions from the dependency right? 

Thank you again
Ayala
--
Ayala Allon, PhD Student
The Visual Working Memory Lab
The school of Psychological Sciences
Tel-Aviv University

Gábor Csárdi

unread,
Jul 5, 2015, 10:52:47 AM7/5/15
to Ayala Allon, rdev...@googlegroups.com
On Sun, Jul 5, 2015 at 4:49 PM, Ayala Allon <ayala...@gmail.com> wrote:
Thank you Gabor.
I have one more question concerning this issue. if I do  what you explained (and of course the put the package name in Imports in the DESCRIPTION file), it means that when one uses my package the dependencies will also be installed if he doesn't have them already

Yes.
 
and package::function() will exact the functions from the dependency right? 

I am not sure what you mean here, sorry. If `package` is installed, and it has `function`, then yes `package::function` will work.

Gabor

ps. this is really an R-help question, it has not much to do with devtools.

Ayala Allon

unread,
Jul 5, 2015, 10:54:47 AM7/5/15
to Gábor Csárdi, rdev...@googlegroups.com
Yes this is what I meant.
Thank you again
Ayala
Reply all
Reply to author
Forward
0 new messages