install_github downloads blank master.zip - r

I have put a test R project on GitHub (here), and am trying to install using the following:
devtools::install_github('HamiltonBlake/test')
I get the following output:
Installing github repo test/master from HamiltonBlake
Downloading test.zip from https://github.com/HamiltonBlake/test/archive/master.zip
Installing package from C:\Users\Ham\AppData\Local\Temp\RtmpAzTLDT/test.zip
Error: Does not appear to be an R package (no DESCRIPTION)
If I manually go to https://github.com/HamiltonBlake/test/archive/master.zip and download it, it's a zipped folder with server.R and ui.R as expected.
However when I go to my Temp folder, the zipped folder which has been downloaded above contains an empty file called "file236447a6420", and an empty folder called "rs-graphics-3f4820b1-7366-461a-b095-f2106ef72e73".
I found this question which made it look like it's a matter of waiting a few hours, however unlike this question, I can download and install from the same path that install_github uses, so it looks like github has already updated the master.zip.
I have full read/write access on my PC, and the latest devtools and rtools.

The description of install_github says
Attempts to install a package directly from github.
If you have ui.R and server.R that implies you actually have a shiny app - not a package.
You'll want to look into the runGitHub function in the shiny package if you want to run directly from github or you can clone the repository locally and use runApp.

Related

Folder in github is missing when installed as R package

I have a public R package in github.
What I did was installed that package using the below commands
install.packages("devtools")
library(devtools)
install_github("ohdsi/Aphrodite") #APHRODITE is the package name
library(Aphrodite)
But I would like to make some changes to the way the package works.
Basically, I would like to make changes to the functions.R file under R folder in github.
As I used install_github command, I already have the package downloaded to my repository.
But I don't see the functions.R under R folder in my downloaded packages folder (APHRODITE).
Can help me understand how can I find the files to make changes?
Note: My appearance settings is set to show all hidden files and folder as well.
In github I see the below whereas in the downloaded packages folder (APHRODITE), I see something different. How can I find the functions.R file to make changes to the code locally?

How do i keep source files when using R's devtools library function 'install'

I am trying to build an R package (DESeq2) from source so that I can debug it. I've installed all the dependencies required and I'm following Hillary Parker's instructions for creating R packages. I'm running this on CentOS 6.6 using R-3.4.2.
I run :
library("devtools")
install("DESeq2", keep_source=TRUE)
It installs it in the directory with all my other R libraries. When I look at the installed DESeq2 library it is missing all the DESeq2/R/*.R and DESeq2/src/*.cpp files.
QUESTION : Where are these files and why didn't they get installed? This does not seem like the expected behavior.
R uses binary database format for installed packages to pack the objects into a database-alike file format for efficiency reasons (lazy loading). These database files (*.rdb and *.rdx) are stored in the R sub folder of the package installation path (see ?lazyLoad).
Even if
you are looking at the right place to find the installed package (use .libPaths() in R to find the installation folder)
and you have installed the package with the source code (like you did or
via install.packages("a_CRAN_package", INSTALL_opts = "--with-keep.source"))
you will not find R files in R folder there.
You can verify that the source code is available by picking one function name from the package and print it on the console. If you can see the source code (with comments) the package sources (R files) are available:
print(DeSeq2::any_function)
To make the source code available for debugging and stack traces you can set the option keep.source.pkgs = TRUE (see ?options) in your .Rprofile file or via an environment variable:
keep.source.pkgs:
As for keep.source, used only when packages are
installed. Defaults to FALSE unless the environment variable
R_KEEP_PKG_SOURCE is set to yes.
Note: The source code is available then only for newly installed and updated packages (not for already installed packages!).
For more details see: https://yetanothermathprogrammingconsultant.blogspot.de/2016/02/r-lazy-load-db-files.html

R: Error in install.packages : cannot open the connection

I was trying to install the package RINDSEL but I am unable to install it and I keep getting the following error:
Error in install.packages : cannot open the connection
I downloaded the package from:
rindsel_1.0_2.zip | Integrated Breeding Platform
and loaded it from the directory. Other packages from the directory can be installed but just not this one.
Is the package corrupt or could there be any other error?
I would really be grateful for any help. Thanks in advance
Rename the zip file RinSel Software into Rindsel. That's the name specified in the discription file.
Then, you can install the package in R with the command
install.packages("C:/path/to/Rindsel.zip",repos=NULL,type="win.binary")
That works fine... at first (!!!).
Problem with the Rindsel package is. It is quite old. It was build with R 2.13.1. Therefore, if you want to load the library which would be the next step to use the package in R you will get the error:
Problems building package (Error: "package has been build before R-3.0.0")
My suggestion: Contact the authors of the package and ask them if they can either provide the source file that you can build the package by yourself or if they can bundle the Rindsel package with a newer R version.
(Or you could try to hunt down an old R version and see if you can get the thing running with an old R... However, I would not seriously suggest to do that. It would probably result in conflicting dependencies with the other required packages...)
EDIT 15-02-2018: OP asked if one can build an R package with sources that are presumeably the Rindsel source files.
Yes, basically, you could do that. You would have to make a your own description and namespace file and put the source file in the R folder than invoke the command in R to build it....
But it's not neccessary with the script files provided by the link the OP posted.
OP, just run the scripts in R! It's quite easy.
Download the zip-file and extract it on your machine.
Go to that directory. The R command would be
setwd('path/to/your/directory')
Than run the R script, e.g, the KNIndex.r. It's simple:
source('KNIndex.r')
Then the script will run and produce some output / prompts.
For future readers,
I was able to fix the error by running RStudio with administrative privileges to get the command to work.
If that does not fix it, you might wish to try
Installing "r tools" if that is not installed already. That can be downloaded from
https://cran.r-project.org/bin/windows/Rtools/
Download a relevant package that you are trying to install (e.g., tidyverse_1.3.0.zip) from https://cran.rstudio.com/
and install that from local path
It can also be installed directly from the web using install.packages("https://cran.rstudio.com/bin/windows/contrib/4.0/tidyverse_1.3.0.zip")
I had the same problem. R was not able to extract and compile the package files to the default installation directory for some system-specific reasons (not R related).
I was able to fix this by specifying the installation directory of the package lib using:
install.packages("your package", lib = 'path/to your/required/installation/directory')
You can then load the package by specifying the lib.loc option while loading it:
library('your package', lib.loc='path/to your/required/installation/directory')
A better solution:
Create a new environment variable (if you are using windows) R_LIBS_USER with the following directory path/to your/required/installation/directory.
This will change the default installation directory of the packages and make it easier to load and install them without specifying the location everytime.

offline installation of packages in R - empty index file generated

I am trying to install packages on a remote windows machine with no internet connection using source packages. I am trying to follow the instructions given in an answer to the previous question
Offline install of R package and dependencies
I have a folder with .tar.gz files for the package and it's dependencies. I run the commands
library(tools)
write_PACKAGES()
which generates the PACKAGES and PACKAGES.gz in the same folder. However, my PACKAGES file is empty (with size 0 KB).
When I try to install the package using
install.packages("<PACKAGE_NAME>", contriburl = "file:///")
(I am in the same directory as all the source files), I am getting the following error
cannot open compressed file '//PACKAGES', probable reason 'No such file or directory'
I am not sure if there is something wrong with the way I specify the path or is it because my PACKAGES file is empty that I am getting this error.
Any help here would be great!
Additional info - The remote machine is a Windows machine and I have also tried deleting the PACKAGES.gz file before installing (as recommended in the link above), but did not succeed.
Thanks!
SN248
I was able to install the package that I wanted (package name = dplyr), using the hints in the comments above. I needed to change two things
I downloaded windows binaries instead of source files, using type = "win.binary" parameter in the download.packages command.
The path in contriburl = "file:///" needed to be changed to contriburl = "file:///<ABSOLUTE_PATH_TO_FOLDER_WITH_WIN_BINARIES>"
With these changes, the package installation went successfully.
Hope it helps others.
SN248

How to build R package from GitHub?

I try to build fork of R package from github (this fork has a fresh bugfix). I am able to build AND install the package from github:
require(devtools)
install_github("patcpsc/rredis", build_vignettes = FALSE)
However, this doesn't produce installable package - or does it? I need to install this package on 15 machines so I prefer to build the package once and then copy and install it on the other machines.
I tried to look for funciton like build_github, unfortunatelly there is none. How do I do it?
github has help documentation on how to fork a repository. It sounds like you've done the first part. Now you just need to clone the repository. That means taking a copy for your local machine so you can work on it. The buttons you want are on the right. Clone in desktop is for when you use the Github desktop software. If you are running git from a command line, type
git clone git#github.com:whatever-the-link-is-in-the-SSH-clone-url-textbox
Once you have a local copy of the repository, in R you do
library(devtools)
build("path/to/package/root")
I thought you wanted to actually work on the package. If you just want to download the source, there's a "Download ZIP" button right underneath the clone options. Download, unzip, then build in R as above.
It's old question and a lot changes since 2014. Now the workhorse is remotes package.
If you want installable package there is one created in your temp directory.
I usually don't want install so I create temporary library:
dir.create(tmp_lib <- "tmp_lib")
.libPaths(c(tmp_lib,.libPaths()))
.libPaths()
But you can skip that if not needed, now standard:
require(devtools)
install_github("patcpsc/rredis", build_vignettes = FALSE)
Now navigate to your temp location given by tempdir() (in Windows shortcut is: shell.exec(tempdir())).
You should see folder [fileXXXXXXXX] which should contain rredis_1.6.9.tar.gz file. This is what you need.
unlink(tmp_lib, recursive=TRUE) cleanup your temp directory.

Resources