Step1:- Install R base(64 bit) and R Studio on PC.
Step2:- Insert Pendrive or location on PC where the offline package folder is kept.
Step3:-. Open R studio in edit mode(R script).
getDependencies <- function(packs){
dependencyNames <- unlist(
tools::package_dependencies(packages = packs, db = available.packages(),
which = c("Depends", "Imports"),
recursive = TRUE))
packageNames <- union(packs, dependencyNames)
# Remove base dependencies, these are installed with R and not published on CRAN
basePackages <- c("base","compiler","datasets","graphics","grDevices","grid",
"methods","parallel","splines","stats","stats4","tcltk","tools","utils")
packageNames <- setdiff(packageNames, basePackages)
packageNames
}
packages <- getDependencies(c("tidyverse", "pacman"))
setwd("E:/offline package R installation")
pkgInfo <- download.packages(pkgs = packages, destdir = getwd(), type = "win.binary")
# Save just the package file names (basename() strips off the full paths leaving just the filename)
write.csv(file = "pkgFilenames.csv", basename(pkgInfo[, 2]), row.names = FALSE)
Step5: after taking desire package in excel sheet as well as packages in a folder take it store it wherever you want. after that open R editor on any other computer.and execute following code
# Set working directory to the location of the package files
setwd("E:/offline package R installation")
# Read the package filenames and install
pkgFilenames <- read.csv("pkgFilenames.csv", stringsAsFactors = FALSE)[, 1]
install.packages(pkgFilenames, repos = NULL, type = "win.binary")
Finally now you can easily use offline package with its deoendancies on any computer without any internet connection