简体   繁体   中英

Don't expose functions from imported packages in own package in R

I know this is a real beginners question, and I'd be happy to any pointer to any help. But I found it quite complicated to find some more or less easy to read resource.

So the question is that I want to create a package in R. Let's say I want to use many functions from the dplyr -package. So I do a @import dplyr at the top of my utils.R where I have many small functions that do some data cleaning etc..

Now when I load all my own functions with devtools::load_all() and start typing the name of my package and :: I get suggestions for all the functions from the dplyr-package as well.

What essential aspect am I missing here?

You can either import only specific functions from dplyr using the line

@importFrom dplyr usefulFunction

which reduces the number of functions that you'll have problems with, or you can remove the import totally, and then refer to functions including the package name, for example dplyr::usefulFunction() whenever you use a function from dplyr .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM