3

I need to support an R environment on a Windows 7 PC that doesn't have internet access.

I'd like to download (to DVD, eventually) a current version of all ~ 5,000 packages to make available to users of R on this PC.

Is there an FTP script, or another good way, to download all of the zip files for the R packages?

I know there are daily updates to R, but one good day will be enough to get me started.

Andy Clifton
  • 4,926
  • 3
  • 35
  • 47
Gerry
  • 1,303
  • 1
  • 10
  • 16
  • Gerry, if either of the answers below work for you, could you select one as the answer? Just click the tick mark. Thanks! – Andy Clifton Dec 18 '13 at 18:41

2 Answers2

5

Presumably you have an installation somewhere that does have internet access. I would just set that installation to download everything. There's an example at http://www.r-bloggers.com/r-package-automated-download/. Start R, and try this:

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

Once you have these files, copy them to some kind of portable media (thumb drive, hard drive, whatever) or burn a CD / DVD and take that to the standalone machine.

Note: there may be a reason this other machine was not connected to the internet. So be careful! Make sure the virus protection is up to date on the non-connected machine, and that your IT folks won't come down on you like a ton of bricks for transferring data this way.

Next, you need to point the standalone machine at the portable media or the CD / DVD. A simple way to do this is to redefine where R looks for the repository. See e.g. Creating a local R package repository for examples.

In your case, try something like this in R:

update.packages(repos="complete-path-to-portable-media",repos = NULL, type = "source")
Andy Clifton
  • 4,926
  • 3
  • 35
  • 47
2

Use rsync to create a mirror and then install packages by pointing to your local mirror as the repos argument of install.packages. No need to make the repository publicly available. Specialize the path (e.g., to rsync based on /bin/windows/contrib/3.0/) to retrieve just the windows binaries (to a directory that you've created with similar structure repos/bin/windows/contrib/3.0/) if that's all that needs to be supported.

rsync -rtlzv --delete \
    cran.r-project.org::CRAN/bin/windows/contrib/3.0/ \
    repos/bin/windows/contrib/3.0/
Martin Morgan
  • 45,935
  • 7
  • 84
  • 112
  • Thanks! I'm on windows, so I needed to find an rsync. The free version at https://www.itefix.no/i2/content/cwrsync-free-edition seems to be working fine -- I'm downloading lots of debian packages at the moment. So, just one more question: is there a way using rsync to just get the windows versions? I don't see anything at teh CRAN Mirror HOWTO page. – Gerry Dec 15 '13 at 00:12
  • I've elaborated a bit in my answer -- instead of rsync'ing from the root, rsync from the root of the windows contrib directory of the version of R you're interested in making available. – Martin Morgan Dec 15 '13 at 00:22
  • The first solution above is working perfectly, so I'm abandoning this solution for now. I can see definite advantages with this approach if I needed to keep up to date versions, but I think I can get by with updating once a month or quarter, so I'm using the inside-R solution for now. – Gerry Dec 15 '13 at 00:38