Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
322 views
in Technique[技术] by (71.8m points)

r - Installing a package offline from GitHub

I'm trying to port some packages to an R installation on an offline (Windows) computer.

From CRAN (let's say data.table), the process: 1) download .zip on separate online computer 2) thumb drive -> offline computer 3) install via install.packages("....zip"...) works exactly as expected.

However, this process broke down when I tried to install from GitHub.

When I run install.packages (note: I'm using type="binary" and repos=NULL; type="win.binary" does nothing either) on the zip file (obtained by going to the package page, e.g. https://github.com/Rdatatable/data.table, and using the "Download .zip" function), something goes wrong.

There's no error message (and nothing new from setting verbose=TRUE), and the package folder is added to my library (i.e., I can see the folder named "data.table-master" when I navigate there), but library(data.table) results in the error: "there is no package called data.table". I also noticed that, while the installation from CRAN finishes with "package data.table successfully unpacked and MD5 sums checked", I get no such message from an attempted GitHub installation.

What's going on here? I tried all possible leads in ?install.packages, but given I'm not really getting an error message it's been hard to diagnose what exactly is the issue.

More background: R version is 3.2.0. Hard to copy-paste sessionInfo since that computer's not online, not sure what else may be relevant.

Update:

Given @r2evans' comments below, I also tried using type="source" with install.packages, and this didn't work either (same problem--despite having "data.table-master" folder in one of my .libPaths() addresses, library(data.table) gives the error that there's no such package).

I did get some more output from using verbose=TRUE this time, however:

system (cmd0): C:/PROGRA~1/R/R-32~1.0/bin/x64/R CMD INSTALL

1): succeeded 'C:/PROGRA~1/R/R-32~1.0/bin/x64/R CMD INSTALL -l "C:UsersMikeDocumentsRwin-library3.2" "E:/data.table-master.zip"'

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Let's assume that you have Rtools and devtools on the win machine.

Step 1: Download the source zip.

Step 2: Copy to the win machine and unzip the content there.

Step 3: Run the following code (adjust the path as necessary):

library(devtools)
source <- devtools:::source_pkg("E:/temp/data.table-master")
install(source)

library(data.table)
#loads 1.9.7

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...