Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error in R CMD Check: Packages required but not available

Tags:

r

packaging

I am trying to create a package. It depends on several packages. I added the imports to the namespace file and the Depends in the description file.

I found possible solutions here and here, but these didn't work- I think because I am on CentOS.

This is what I see on my screen:

[hadoop@localhost RProjects]$ sudo R CMD check TextPreProcess
* using log directory ‘/home/hadoop/RProjects/TextPreProcess.Rcheck’
* using R version 2.15.1 (2012-06-22)
* using platform: x86_64-redhat-linux-gnu (64-bit)
* using session charset: UTF-8
* checking for file ‘TextPreProcess/DESCRIPTION’ ... OK
* checking extension type ... Package
* this is package ‘TextPreProcess’ version ‘1.0’
* checking package namespace information ... OK
* checking package dependencies ... ERROR
Packages required but not available:
  ‘RWeka’ ‘Snowball’ ‘lsa’ ‘plyr’ ‘snowfall’ ‘tau’ ‘tm’

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

I went through Writing R Extentions but I couldn't derive a lot of insight as to how to solve my problem.

like image 577
jackStinger Avatar asked Jan 16 '13 12:01

jackStinger


2 Answers

It's working now.

What I did was:

  1. add ~/R/x86_64-redhat-linux-gnu-library/2.15 to .libPaths (That's where my R library was)
  2. Detach all libraries in R
  3. Restart the R session. (For multiple sessions, close all of them.)
  4. install the required packages.
  5. Check if the Imports & Exports are correct in the namespace file.
  6. Check if the required fields are available in the Description file. Make sure all dependencies are handled between 'Depends', 'Imports', 'Suggests' and 'Enhances'.
  7. Checked it. R CMD check <pkg>. Built it. R CMD build <pkg>. Installed it. R CMD INSTALL <tarball>.
  8. Done.
like image 118
jackStinger Avatar answered Nov 07 '22 23:11

jackStinger


I had the same problem because packages were installed but for different R versions.

To solve, I opened the old R version (the one the package was built under), and installed the missing packages under that version and it solved the problem.

E.g.

# Version should match the version your package was built in
R.version
# 3.5.1

install.packages(c('stringr', 'lubridate', 'testthat'))

Tips

  • If you need to check your R version, simply type R.version
  • If you need to switch R version, hold control while starting RStudio on windows, or on mac download a very simple application called RSwitch to instantly switch between version (you'll still need to restart the R session with .rs.restartR()
like image 22
stevec Avatar answered Nov 07 '22 22:11

stevec