I created a R package called myPackage
. In that package I've used other packages, such as, RJSONIO
, stringr
, RSQLite
and Rcpp
. I want to install all of those packages when I am installing myPackage
, if it is not installed before.
Is this possible?
You can specify a list of packages in the DEPENDS
section of your DESCRIPTION file. From the linked documentation file
The ‘Depends’ field gives a comma-separated list of package names
which this package depends on. The package name may be optionally
followed by a comment in parentheses. The comment should contain a
comparison operator, whitespace and a valid version number. You can
also use the special package name ‘R’ if your package depends on a
certain version of R — e.g., if the package works only with R version
2.11.0 or later, include ‘R (>= 2.11.0)’ in the ‘Depends’ field. You can also require a certain SVN revision for R-devel or R-patched, e.g.
‘R (>= 2.14.0), R (>= r56550)’ requires a version later than R-devel
of late July 2011 (including released versions of 2.14.0). Both
library and the R package checking facilities use this field: hence it
is an error to use improper syntax or misuse the ‘Depends’ field for
comments on other software that might be needed. Other dependencies
(external to the R system) should be listed in the
‘SystemRequirements’ field, possibly amplified in a separate README
file. The R INSTALL facilities check if the version of R used is
recent enough for the package being installed, and the list of
packages which is specified will be attached (after checking version
requirements) before the current package, both when library is called
and when preparing for lazy-loading during installation.
There are other related sections, such as IMPORTS
and SUGGESTS
- see the docs for details.
Have a look at some of the R-packages on r-forge to get an idea.