Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

install a R package needed for your package upon installation

I'm developing a R package that depends on another R package being installed on the users system.

I've added a Depends:pkgname in the DESCRIPTION file and import(pkgname) in the NAMESPACE. What I was hoping this would do is check if pkgname is already installed and if not install.packages(pkgname,repos="CRAN or Rforge or wherever the package is") if not.

However upon attempted installation of my package i get the error:

    ERROR: dependency 'pkgname' is not available for package 'mypkg'

Does anyone know how to implement an installation of pkgname, should pkgname not already be on the system?

Many thanks

like image 414
Sebastian Avatar asked Oct 09 '22 08:10

Sebastian


1 Answers

In the help file of R CMD INSTALL there is no mention of a flag to install additional packages if needed for dependencies. If you submit your package to CRAN, your problems are solved because install.packages then solves any dependencies. install.packages does not support solving dependencies when installing from a local file.

Until you submit to either R-forge or CRAN, I think it will suffice to add a remark to the README file that a few additional packages need to be present. You could even post a snippet of R code containing the needed install.packages command.

like image 188
Paul Hiemstra Avatar answered Oct 13 '22 10:10

Paul Hiemstra