[R] Installing packages from command line on Linux RHEL4

Dirk Eddelbuettel
2007-05-21T17:59:39Z

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

	repos="http://cran.us.r-project.org"

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")
  q()
}

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
~/.Rprofile.

Hth, Dirk

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