Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to tell CRAN to install package dependencies automatically?

Tags:

r

cran

r-forge

I develop a package in R and when I check and build it in my local computer it works properly. But when I tried it in CRAN, I get a package dependencies error. My package depends on two functions of other packages.

If I list the other packages under the description using Depends or imports, will it be automatically installed with the new package? Or do I need to explicitly invoke the function install.packages("packagename") under the function that I've used the other packages. if this all is wrong, what is the best way to solve package dependencies in R inorder to pass the R CMD check and build test and submit to CRAN?

Thank you.

like image 747
Mikael Avatar asked Jan 05 '13 11:01

Mikael


People also ask

Does apt automatically install dependencies?

Unfortunately, apt command does not have an option to automatically download and install all required dependencies for a package. You need to determine and then install dependencies manually, or run a single command to resolve all dependency issues in your system.

How can we install packages in R with all dependencies?

Remember in R, Boolean (TRUE and FALSE) must be all capital letters or R will not recognize them as Boolean. At the top, got to Tools and select Install Packages from the drop down. Finally, make sure install dependencies and checked and click install.

How do I add packages to CRAN?

To manually submit your package to CRAN, you create a package bundle (with devtools::build() ) then upload it to https://cran.r-project.org/submit.html, along with some comments which describe the process you followed.

What does the installed packages () function do?

installed. packages scans the DESCRIPTION files of each package found along lib. loc and returns a matrix of package names, library paths and version numbers.


2 Answers

On your own system, try

install.packages("foo", dependencies=...) 

with the dependencies= argument is documented as

dependencies: logical indicating to also install uninstalled packages       which these packages depend on/link to/import/suggest (and so       on recursively).  Not used if ‘repos = NULL’.  Can also be a       character vector, a subset of ‘c("Depends", "Imports",       "LinkingTo", "Suggests", "Enhances")’.        Only supported if ‘lib’ is of length one (or missing), so it       is unambiguous where to install the dependent packages.  If       this is not the case it is ignored, with a warning.        The default, ‘NA’, means ‘c("Depends", "Imports",       "LinkingTo")’.        ‘TRUE’ means (as from R 2.15.0) to use ‘c("Depends",       "Imports", "LinkingTo", "Suggests")’ for ‘pkgs’ and       ‘c("Depends", "Imports", "LinkingTo")’ for added       dependencies: this installs all the packages needed to run       ‘pkgs’, their examples, tests and vignettes (if the package       author specified them correctly). 

so you probably want a value TRUE.

In your package, list what is needed in Depends:, see the Writing R Extensions manual which is pretty clear on this.

like image 77
Dirk Eddelbuettel Avatar answered Sep 27 '22 22:09

Dirk Eddelbuettel


Another possibility is to select the Install Dependencies checkbox In the R package installer, on the bottom right:

enter image description here

like image 30
sivi Avatar answered Sep 27 '22 21:09

sivi