Add non-github dependencies to github R package? - r

I am building an R package and posted it on github. It is supposed to depend on stringr ... yet despite adding it to the "depends" and "imports" portions of the DESCRIPTION, it seems to have issues installing automatically (is it looking for stringr on github also?).
Here is the command I am running (imagine a fresh R install):
install.packages("devtools")
devtools::install_github("tcarpenter216/packagename")
[replaced my packages name above with 'package name'] ... this is returning the following error:
Downloading GitHub repo tcarpenter216/packagename#master
Error in pull_off("#(.*)$") :
cannot open file '/Users/tcarpenter/Library/R/3.2/library/stringr/R/stringr.rdb': No such file or directory
Any idea how to put dependencies on a package hosted on github? Is it obvious what I'm doing wrong?

You are confusing packages, packages dependencies and what repositories such as CRAN can do -- with just dropping code onto GitHub.
GitHub source code repositories do not resolve dependencies.
GitHub source code repositories are not R code repositories.
However, you can turn them into such R code repositories, and that is what my drat packages (on CRAN and GitHub) does. So see its simple documentation, included in the package. It fills the void you identified here.

Related

Make CRAN R package suggest GitHub R package

I want to use the R package BOLTSSIRR available on GitHub in my R package, which I want to upload to CRAN.
I listed BOLTSSIRR under Suggests: in the DESCRIPTION file and made the link to GitHub available using Additional_repositories: https://github.com/daviddaigithub/BOLTSSIRR.
However, running R CMD check --as-cran I get:
Suggests or Enhances not in mainstream repositories:
BOLTSSIRR
Availability using Additional_repositories specification:
BOLTSSIRR no ?
? ? https://github.com/daviddaigithub/BOLTSSIRR
Additional repositories with no packages:
https://github.com/daviddaigithub/BOLTSSIRR
So the GitHub link does not seem to get recognized in the check. Might I have to change something here?
As you found, you can't use Remotes in a CRAN package. What you need to do is to make sure the .tar.gz file for the package you are depending on is available somewhere. Github doesn't do that automatically, because https://github.com/daviddaigithub/BOLTSSIRR isn't set up as a package repository.
The solution is to create your own small repository, and keep copies of non-CRAN packages there. The drat package (available here: https://github.com/eddelbuettel/drat) makes this easy as long as you have a Github account: follow the instructions here: https://github.com/drat-base/drat. In summary:
Fork https://github.com/drat-base/drat into your account, and clone it to your own computer.
Enable Github Pages with the docs/ folder in the main branch.
Install the drat package into R using remotes::install_github("eddelbuettel/drat"). (I assume this version will make it to CRAN eventually; if you use the current CRAN version instructions are slightly more complicated.)
Build the package you want to insert. You need the source version; you might want binaries too, if those are hard for your users to build.
Run options(dratBranch="docs"); drat::insertPackage(...) to insert those files into your repository.
Commit the changes, and push them to Github.
In the package that needs to use this non-CRAN package, add
Additional_repositories: https://yourname.github.io/drat
to the DESCRIPTION.
You will be responsible for updating your repository if BOLTSSIRR is updated. This is good because the updates might break yours: after all, it's still in development mode. It's also bad because your users won't automatically get bug fixes.
That's it, if I haven't missed anything!

R Package Dependency in Github via Remotes not working

I'm developing an R package in Github (ConceptionTools) that depends on another R package (CreateFlowChart), also in Github. I have followed the instructions for defining remote dependencies. My DESCRIPTION file includes:
Imports: CreateFlowChart
Remotes: github::IMI-ConcePTION/CreateFlowChart
However, when I install my package, with the command:
devtools::install_github("IMI-ConcePTION/ConceptionTools")
This dependency is not installed. I simply get "skipping 1 packages not available: CreateFlowChart". It doesn't appear to be trying to use the Remote, since there is no error related to Github.
When I install the dependency directly, that works:
devtools::install_github("IMI-ConcePTION/CreateFlowChart")
Does anybody have any idea of what could be going on here? I'm racking my brain, as it seems to be a quite straightforward case of what the documentation shows. I'm using R 4.0.3 (on Windows 10) and devtools 2.3.2.
There was a typo in the name of the dependency package in its DESCRIPTION file.
This does not make the package fail when installing it directly, but it leads devtools not to find it as a dependency.

submit an R package with CTAN dependencies to CRAN

I am currently working on an R package that is going to be submitted CRAN within a few weeks. The package needs some latex packages to run. Those latex packages are available on CTAN and injected in the preamble of RMarkdown documents via rmarkdown::latex_dependency().
This is the concept of my actual knit_print method.
#' #export
knit_print.my_class <- function(obj, ...) {
knitr::raw_latex(
to_latex(obj),
meta = list(
rmakrdown::latex_dependency(
"ragged2e"
)
)
)
}
My question is how those dependencies can be specified in a way such that CRAN is going to accept this submission. As far as I can tell, there are four options
submit the package as-is and add installation instructions via the documentation and the SystemRequirements field of the DESCRIPTION file.
include all necessary latex packages in my R package and somehow make them available to the client's latex compiler
add a dependency to tinytex which can install CTAN packages automatically
Throw an error during installation if the dependencies are not met
So far, I used option (1).
My configuration for travis (ubuntu 14.04) is
apt install texlive-latex-extra
tlmgr install standalone
For appveyor (Windows Server 2012 R2 x64), I unpack miktex-portable.exe and add it to the PATH. Then I get the following packages.
mpm --install=standalone
mpm --install=ms
mpm --install=pbox
mpm --install=xcolor
mpm --install=colortbl
mpm --install=mptopdf
What I found out so far
using google to search for external dependencies and CRAN sumbissions only yielded information about C and C++ dependencies, which didn't help my cause.
Looking at some source code revealed that rticles include certain .sty files directly in inst/ which leads me to believe, that (2) is the correct answer. However, rticles defines custom output formats and those don't have to "install" the latex packages since the .sty files are copied to the render directory as part of a template.
magick uses a config file that prevents the installation in case (system) dependencies are not met. It also throws an informative error message that instructs the client how the dependencies can be met.
the tinytex package did not run any compile tests on CRAN when it was submitted. I also can't make tinytex it work on appveyor
I am reasonably familiar with the CRAN Repository Policy and there is generally no provision for external dependencies off CRAN etc.
That said I stretched CRAN a little to by downloading pre-built libraries off GitHub as needed. You could model your package after that.
But what I really think you should do is to ... prepare your pdf vignette locally and then have the R package 'inject' it as is. How to do that is explained eg in this post by Mark and I just converted my RcppAnnoy package to do just that. Of course, YMMV.

Bioconductor packages Not Installing with biocViews specification in Description section of Package

Problem:
I am developing an R package and one of the dependent packages is multtest.
It's only available on Bioconductor as here. I am using devtools to build the package. And, when I run devtools::install() on R console, I would like multtest to automatically install as with my other CRAN packages if it is not already installed. I do know how to install Bioconductor packages manually.
Researched Solutions:
The following links suggest that I should put
biocViews:
in the Description file of the package for automatic installation of the Bioconductor packages.
biocViews: is in the line above Imports: (I am not sure where it is placed matters as much?) and the Bioconductor package to be installed is put under Imports: as here
biocViews: is in the line above Imports: and the Bioconductor package to be installed is put right after like biocViews: multtest. This exact answer is at the end of a non-voted thread in response to Vivian by Vivekbhr as here
I have also followed up and checked the description file of the packages which rely on Bioconductor as here
Attempted Solutions:
I have followed those research solutions by putting multtest along with biocViews:, below biocViews:, under Imports:. All of them came back with package dependency or package not found errors as in the pictures below.
biocViewsinOneLine
biocViewsinSeparateLine
biocViewsunderImports
Then, I manually re-installed multtest and it works. However, I still would like to have the automatic installation capability as mentioned here under the Imports section in Hadley's book as here
Is it possible? Am I misunderstanding something or doing something wrong?
Thank you very much!
I have tried your 3rd method, and it could pass the CMD check. Maybe update your devtools?
You need to add multtest under Imports in DESCRIPTION.
However, as `multtest' is from Bioconductor link, add to DESCRIPTION
biocViews: Software, BiologicalQuestion

Create an R package that depends on another R package located on GitHub

I am creating an R package on GitHub, LW1949, that depends on another R package on GitHub, jvamisc. When I try to install LW1949 using
require(devtools)
devtools::install_github("user/LW1949")
I get the message: Skipping 1 packages not available: jvamisc.
How can I point the import(jvamisc) part of the LW1949 package (in NAMESPACE) to Github instead of CRAN to find this dependency?
Surely this question has been asked and answered before, but I was not successful searching for it (perhaps because the search terms are so common - R, package, GitHub, etc.). I did stumble across Travis CI and Packrat, neither of which I've used. No idea if they would help. I would prefer as simple a fix as possible. (Wouldn't we all?)
I'm using R version 3.1.3 for Windows in R Studio Version 0.98.1103.
This question seems to have been answered quite recently, addressed in this issue of the devtools' github repository.
Package developer POV:
do:
usethis::use_package("jvamisc")
devtools::document()
to add the dependency in the Imports field of your DESCRIPTION file.
manually add a field "Remotes:" in the DESCRIPTION file, specifying where on github R should look for the package:
#in DESCRIPTION
Imports: ...,
jvamisc,
...
Remotes: JVAdams/jvamisc
End-user POV:
the end user has to have the latest development version of devtools (or at least the one corresponding to commit #f21ca3516c). You have to somehow 'force him' to update his devtools version (I guess just put this in the installation instructions... Can't think of a better way)
devtools::install_github(“hadley/devtools”, ref = “f21ca3516c”)
Restart the R Session on unload/reload the devtools package.
do the usual install_github:
require(devtools)
devtools::install_github("user/LW1949")
I guess this functionality will be added sooner or later to the CRAN version of devtools, so there will be no need for the user to fetch the dev version and he would go directly to step 3).
The steps and additional options are detailed in this vignette.
The actual solution seems to add in your DESCRIPTION file the line
Remotes: hadley/testthat
see the documentation of devtools :
# Git
Remotes: git::https://github.com/hadley/ggplot2.git
# Bitbucket
Remotes: bitbucket::sulab/mygene.r#default, dannavarro/lsr-package
# Bioconductor
Remotes: bioc::3.3/SummarizedExperiment#117513, bioc::release/Biobase
# SVN
Remotes: svn::https://github.com/hadley/stringr
# URL
Remotes: url::https://github.com/hadley/stringr/archive/master.zip
# Local
Remotes: local::/pkgs/testthat
# Gitorious
Remotes: gitorious::r-mpc-package/r-mpc-package

Resources