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
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"
)