1

My institute uses proxy server, and no one is able to install packages in a usual way. (i.e downloading binary file from CRAN and then choosing Mirro and the installing etc etc).

I am able to install packages if I use internet outside of my institute.

So, I am looking for an offline way to install packages. Please provide a detailed solution, I have just started using R.

Before writing this question I did look at this earlier asked question but did not quite understand the terms which have been used here (they are very direct). I am a newbie, please provide me a detailed solution. Offline install of R package and dependencies

Help will really be appreciated. I am really stuck here. I am not able to do anything.

Thank you.

Community
  • 1
  • 1
Ayush Raj Singh
  • 863
  • 5
  • 16
  • 20
  • So... you can't access the Internet at all? Because even with a proxy, you should still be able to download the binary from CRAN using your web browser, and unzip it. – Hong Ooi Jun 19 '13 at 11:36
  • 1
    What part of the answer to the linked question do you not understand specifically? – Roland Jun 19 '13 at 11:37
  • You can use port 81 which is always opened for normal mailing and inet. And secondly you could download the zip files from the R site or bioconductor. And than install them with install.packages(c(pack1,pack2,pack3)) full zip names required! – Sander Van der Zeeuw Jun 19 '13 at 11:41
  • @Roland Hi, let us say my package zip file's path is C:/Users/Desktop/thezipfile (eg C:/Users/Desktop/ggplot2_0.9.3.1), now how do I use these functions #######install.packages("ggplot2", contriburl="file:///path/to/packages/"),,,,,,,,ibrary(tools) write_PACKAGES("/path/to/packages/")###### ? What is 'path' in this command? Is it "C:/Users/Desktop/thezipfile" for me? – Ayush Raj Singh Jun 19 '13 at 11:56
  • Once you've downloaded the zip file, you don't actually need `install.packages`. You can just unzip it directly into your R library path (which will be c:\program files\R\R-\library in a default installation). – Hong Ooi Jun 19 '13 at 12:20
  • If you're on windows, at least try `setInternet2()` and using the normal installation process first. – hadley Jun 19 '13 at 13:28
  • @HongOoi Thank you very much. Phew. Worked. – Ayush Raj Singh Jun 19 '13 at 14:45

1 Answers1

9

This is my work around. Might be helpful for you too.

Idea: Download packages with their dependencies through internet and install packages offline.

# Set Mirror to download packages    
options(repos=structure(c(CRAN="http://cran.ma.imperial.ac.uk/")))

 # Set Working Directory   
    setwd(file.path(
        "D:"
      , "User"
      , "DownloadingPackagesWithDependencies"
      )
      )


getPackages <- function(packs){
  packages <- unlist(
      tools::package_dependencies(
          packs
        , available.packages()
        , which=c("Depends", "Imports")
        , recursive=TRUE
        )
      )
    packages <- union(packs, packages)
    packages
  }

# Specify Packages to Download with their dependencies also   
Packages <- getPackages(
                c(
                  "ggplot2"
                  )
                )


download.packages(
    pkgs=Packages
  , destdir=getwd()
  , type="source")

# Install packages from local drive
    install.packages(
        pkgs="ggplot2_0.9.3.1.tar.gz"
      , repos = NULL
      , type="source"
       )
MYaseen208
  • 22,666
  • 37
  • 165
  • 309