[R] Installing packages from command line on Linux RHEL4

Dirk Eddelbuettel edd at debian.org
Mon May 21 19:59:39 CEST 2007

Hi Kernit,

On 21 May 2007 at 11:37, Kermit Short wrote:
| Greetings.
|    I am a System Administrator, and thus have very little knowledge of R
| itself.  I have been asked to install a list of some 200 packages (from
| CRAM) to R.  Rather than installing each package manually, I was hoping I
| could script this.  I've written a BASH script that hopefully will do this,
| but I'm wondering about the Mirror Selection portion of the installation
| process.  I've looked and can't find anywhere a parameter to supply that
| specifies a mirror to use so that I don't have to manually select it for
| each package I want to install.  In this case, with nearly 200 packages to
| install, this could become quite tedious.  Does anyone have any
| suggestions?

The narrow answer is try adding 


Also, and if I may, the littler front-end (essentially "#!" shebang support for R)
helps there:

basebud:~> cat bin/installPackages.r
#!/usr/bin/env r
# a simple example to install all the listed arguments as packages

if (is.null(argv)) {
  cat("Usage: installPackages.r pkg1 [pkg2 [pkg3 [...]]]\n")

for (pkg in argv) {
  install.packages(pkg, lib="/usr/local/lib/R/site-library", depend=TRUE)

You would still need to add repos="..." there. I tend to do that in my

Hth, Dirk

Hell, there are no rules here - we're trying to accomplish something. 
                                                  -- Thomas A. Edison

More information about the R-help mailing list