Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

R package dependencies

i'm trying to build a R package, but it seems that there are some problems with the package dependencies. If I run the code in R, I need the packages "rgdal" and "rgeos", so for creatng the package out of it, I:

  • Added the line "import(rgdal, rgeos)" to the NAMESPACE file
  • Added the line "Depends: rgeos, rgdal" to the DESCRIPTION file

When I run R CMD check (after build) I got an error which says:

* checking package dependencies ... ERROR
Benötigte, aber nicht verfügbare Pakete:
  'rgeos' 'rgdal'

See the information on DESCRIPTION files in the chapter 'Creating R
packages' of the 'Writing R Extensions' manual.

German part of the error: "Benötigte, aber nicht verfügbare Pakete:" = "Needed, but not available packages".

I've read the mentioned manual and know about the options of using imports, suggestes or enhances but i'm pretty sure that depends is the option i've to use, because in the functions of my code, i'm using external functions of this both packages.

What am I doing wrong?

like image 481
tobias b. Avatar asked Apr 13 '12 18:04

tobias b.


People also ask

What are package dependencies in R?

A dependency is a code that your package needs to run. Dependencies are managed by two files. The DESCRIPTION manages dependencies at the package level; i.e. what packages needs to be installed for your package to work. R has a rich set of ways to describe different types of dependencies.

How do I install dependencies in R?

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.

What are included in R packages?

R packages contain code, data, and documentation in a standardised collection format that can be installed by users of R, typically via a centralised software repository such as CRAN (the Comprehensive R Archive Network).


1 Answers

R thinks that you do not have the packages on your system.

Now you of course know that you do. What is the difference?

Well you probably have them installed in another directory which R CMD check does not look at. One way to fix this is described in Section 7 entitled "Tools" of the 'R Internals' manual (referenced from 'Writing R Extensions') and uses the file ~/.R/checkEnviron to set environment variables to be used during R CMD check.

For example, I have

# edd Apr 2003  Allow local install in /usr/local, also add a directory for
#               Debian packaged CRAN packages, and finally the default dir 
# edd Jul 2007  Now use R_LIBS_SITE, not R_LIBS
R_LIBS_SITE=${R_LIBS_SITE-'/usr/local/lib/R/site-library:'
                          '/usr/lib/R/site-library:/usr/lib/R/library'}

where I just broke the one long line (there aren't two apostrophes in the middle).

like image 55
Dirk Eddelbuettel Avatar answered Nov 15 '22 22:11

Dirk Eddelbuettel