R Package Automated Download

March 6th, 2011

There are situations where we might want to run R on a standalone machine so need to download a (potentially) large number of packages to install on this system. Rather than having to through the pain of searching through CRAN to find the packages and all the dependencies and manually download, it would be nice to be able grab all available packages in one go and then set them up as a local repository.

There are some functions provided in R that could take away some of the pain. After setting our default repository we can use the available.packages function to generate a list of available packages (no surprise there) and then use the download.packages function to download them to a suitable directory on our PC.

> pkg.list = available.packages()
> download.packages(pkgs = pkg.list, destdir = "C:\\MyRPackages")

This will grab the list of available packages and download them to the directory C:\MyRPackages so that they can be installed as required or burnt to CD/DVD and transferred to the standalone PC.

3 Responses to “R Package Automated Download”

  1. efrique says:

    Before I try that, do you have any idea how many gigabytes that’s going to end up?

  2. Ralph says:

    Mine was just over 2 Gb in total.

  3. Balter says:

    A very good contribution. I’ve been through this situation.