Folder in github is missing when installed as R package - r

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?

Related

Link to vignette from readme.rda

I am building an R package. I have several vignettes that I would like to include links to in my README.Rmd.
I know that vignettes are to be built optionally when installing the package.
I do not really understand where I should start. I am in the process of building the package in R studio. I would the user to be able to see the vignette just by clicking at link in the readme on GitHub. Is this possible? How?
The following obviously does not work.
[The main vignette](vignettes/Vignette.html)
You can do this, but it might be more trouble than it's worth.
The problems are
Your package directories are different in the source on Github than they are when your package is installed in R. The link you give would be fine if you actually put Vignette.html in the vignettes directory, but when your package is installed, it will be in doc.
RStudio won't put the processed vignette in either of those locations by default if you just knit Vignette.Rmd.
You don't normally commit output files on Github.
So here's what you could do to work around this. Make the link look like
[The main vignette](doc/Vignette.html)
To make sure that file is there on Github, in RStudio create the doc directory and run
rmarkdown::render("vignettes/Vignette.Rmd", output_file="doc/Vignette.html")
You'll need to commit the output file and push it to Github, but you don't want to include it when you build the .tar.gz file, so you'll also need to add the lines
^doc$
^doc/Vignette.html$
to the .Rbuildignore file in the main package directory.
With all these changes I think your vignette will be visible on Github and also after you install the package in R.
A much simpler approach is just to tell the user to run
vignette("Vignette", package = "yourpackagename")
after installing the package, but this won't make it visible on Github.

How to install a R package from local folder with the dependencies installation still in same folder? [duplicate]

Suppose I need to install a number of packages on a (Linux) machine that does not have an internet connection. Let's say that I downloaded a copy of cran and burned it on a DVD that I bring to the offline location:
wget ftp://cran.r-project.org/pub/R/src/contrib/*.tar.gz
I can even add a PACKAGES file that contains an overview of all the source packages and their dependencies:
library(tools)
write_PACKAGES()
How could I use this offline to install a source package in such a way that dependencies are resolved and installed from the local files as well? For example, someone wants to install package ggplot2, which has a fairly deep dependency structure. Assume the source package of ggplot2 and all of its dependencies are available as source packages in the current working directory. If I do:
install.packages("ggplot2_0.9.1.tar.gz", repos=NULL)
This results in an error, because the dependencies are not resolved at all. Alternatively:
install.packages(list.files(pattern="*.tar.gz"), repos=NULL)
However this also ignores the dependency structure, and tries to install packages in alphabetical order, which will also fail.
I looked into available.packages and contrib.url but I just can't find an example of installing a source package from a local file including it's dependencies.
The correct answer was given by Joshua Ulrich in the comment on the question:
The key is prefixing the argument to either repos or contriburl with file://. So in Unixy systems one could do:
install.packages("ggplot2", contriburl="file:///path/to/packages/")
This assumes that all required source packages, as well as a PACKAGES index file is available in /path/to/packages. If no PACKAGES file is present, this should be generated first using:
library(tools)
write_PACKAGES("/path/to/packages/")
which will generate an index of all source packages found in this directory. Note that in the example, there are 3 slashes behind the file: prefix. The third slash indicates a path relative to the root of the file system.
The difference between the repos and contriburl argument is that repos will append another /src/contrib to the path specified, as this is usually where source packages are located on an official CRAN repository mirror.
With reference to Answer above, if installation is in Windows, then write_PACKAGES() generates two files: PACKAGES and PACKAGES.gz under '/path/to/packages/' directory where all zip files are placed. The file PACKAGES.gz should be deleted before install.packages() function is correctly able to read the lone PACKAGES file else 'cannot open compressed file' error appears.
I had the same issues during offline installation. Somehow it didn't work by command line.
I downloaded, extracted all the dependencies (Keeping check of the min version required) and pasted the folders in the library folder. This way only my problem got solved.

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.

install_github downloads blank master.zip

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.

Resources