This is a follow-up to a post from 2007: https://stat.ethz.ch/pipermail/r-help/2007-April/129009.html
Summary of the Problem: Packages are correctly installed and can be loaded when R is opened interactively or using a R script. However, a bash scripts produces an error similar to the following: #!/bin/bash ... R --no-save <<EOF ... library(package) Error in library(package) : there is no package called 'package' Execution halted At least two workable solutions exist but appear to apply in different circumstances. Solution found for the original post: Multiple versions of R; R (old): system wide R (new): on my user side only When I started R in the command prompt it was calling the R (new) version because of my .bashrc config. When I was scripting, I was opening a bash that was by passing some of my config file, thus I was running R (old), where scatterplot3d was NOT installed. To solve that I had to make sure I installed only one version of R system wide and then I had to install the package only once and could use it from any origin. To know if you have the same version problem you can save your output of R, from command and in a script, and look at the version number to see if they differ. You can also use > which R both from the terminal and a script to see if they differ. If above does not work or only one version of R is installed: Under some bash scripts, R appears to only look for packages in the R_LIBS_SITE location (/usr/lib/R/library in this instance), where base-packages are stored, and does not look for packages in the R_LIBS_USER location (/home/user/R/*library/2.14 in this instance), where user-installed packages are stored. Both locations are defined in Renviron. To work-around, packages can be copied from R_LIBS_SITE to R_LIBS_USER. Any thoughts or insights would be appreciated. Otherwise, I hope these work-arounds will be useful to others facing a similar error. Best, Leila [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.