1

Really hope somebody is able to help please.

We have a need to run R in an environment which has no access to the internet.

So, working in an online environment, I used the R commands:

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

to download current packages. These were downloaded as tar.gz files. I transferred these to the environment where internet isn't available.

I then tried this command (following advice in Offline install of R package and dependencies):

library(tools)
write_PACKAGES()

to 'index' the packages. This doesn't seem to work, as it didn't create PACKAGES and PACKAGES.gz which it was meant to.

Funnily enough, this worked when I tried with a couple of packages which were .zip files, so figured there is some reason that R cannot recognize the tar.gz files. But in any case, when I tried:

install.packages("ggplot2", contriburl="file:///path/to/packages/")

I had an error message saying that the current version of R didn't support these packages.

So I seem to have a two-fold problem:

  • issue about using the Write_PACKAGES command
  • issue about version history

Would be grateful for any advice on this please.

K.Dᴀᴠɪs
  • 9,945
  • 11
  • 33
  • 43

1 Answers1

1

These were downloaded as tar.gz files.

This appears to be a bug or at least unexpected behaviour in download.packages. The documentation for that function says

type character string, indicate which type of packages: see install.packages.

and on Windows, install.packages with no type specified will download binary rather than source files.

To get around this, you can manually specify type="win.binary" in your download.packages call:

download.packages(pkgs = pkg.list, destdir = "C:\\MyRPackages", type="win.binary")

Once you've done that, you should have a directory of zip files which are your packages. You can then install them with

install.packages("pkgname_x.x-x.zip", repos=NULL)  # not contriburl
Hong Ooi
  • 56,353
  • 13
  • 134
  • 187