Soheil
Soheil

Reputation: 974

Including libraries in a package or main Script

I am building a package for the first time.

The package needs couple of libraries to work. Should I include those libraries in the package for every function? or should I include them in my main Script?

Upvotes: 1

Views: 357

Answers (1)

Paul Hiemstra
Paul Hiemstra

Reputation: 60924

In the DESCRIPTION file in your package you can list the packages your package depends on. This will allow you to use the code from those packages to be used anywhere in your package. So, there is no need for explicit use of library or require. When your package is loaded, the other packages will also be loaded. In addition, when setting dependencies = TRUE in install.packages the packages your package depends on will also be installed (if available on CRAN).

Upvotes: 4

Related Questions