6

I am working on a terminal at work that has no http||https connection due to security protocol. I downloaded manually a few packages on another computer and am trying to install them using RStudio. When I do run in RStudio

install.packages(//filedir/package_file.zip,repos=NULL,type="source")

it is trying to connect to an online repository anyways:

>>warning in istall.packages:
>>unable to resolve 'www.stats.ox.ac.uk'

but when I go through RGui and use utils:::menuInstallLocal() and use the popup window it doesn't try connecting through a server and installs my local files.

What am I doing wrong in RStudio?

I also want to be able to make it that the dependencies and imports install automatically for the parent package when I install it.

rcs
  • 67,191
  • 22
  • 172
  • 153
yonicd
  • 498
  • 1
  • 4
  • 15

3 Answers3

6

Assuming you have your packages in zip archive format local onto your machine.

RStudio has a simple menu option

Tools>Install Packages > Select "Package Archive File" in Install from option

browse your package file you need to install.

Post installation you may like to load the libraries for instance if you have installed "tm" package then you may run the command

library(tm) # load the library "tm"

Hope it works :)

zyduss
  • 91
  • 2
5

Do not use the argument type="source", since you give a link to a zip file:

This should work

install.packages("yourlink.zip", repos=NULL)
Pop
  • 12,135
  • 5
  • 55
  • 68
  • from rstudio: Hi, It looks like we've been forcing checking CRAN for package updates regardless of other settings. [This](http://www.rstudio.com/ide/download/preview) should be fixed in the latest preview - can you try installing that and running it and let us know if it fixes your issue? – yonicd Mar 28 '14 at 08:59
1

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

wishy
  • 23
  • 2