Using a forked and modified version of R GitHub repo - r

I have forked a GitHub repo of an R library and edited some functionalities as per my requirements. I now want to use this new library and its functions in my R script. Is there a way to do this?
I read this https://cran.r-project.org/web/packages/githubinstall/vignettes/githubinstall.html
For ex:
I have forked and edited the repo package textshaping and I want to use this newly edited version something like:
library(username/textshaping)
username/textshaping::text_width("Seven sea\'s seacod")

Related

Sometimes updated functions are not downloaded when using R package from GitHub

I am publishing an R package to GitHub (IDOJI/refineR).
I use Github desktop to update the package.
If I modify some functions, then I always update my repo.
And it works well so that I can find my functions have been updated on my Github.
However, sometimes some updated functions are not downloaded from my repo.
More specifically, the downloaded function is not an updated version.
I use this line to download the package.
devtools::install_github("IDOJI/refineR", force=T)
Do you have any ideas?

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 packages for symbolic regression

I want to carry out a symbolic regression with R. The rgp package is the most recommended package on the internet but it was removed from CRAN.
https://cran.r-project.org/web/packages/rgp/index.html
Does anybody know some other equivalent packages in R?
An alternative package is the gramEvol package (on CRAN).
I wrote a blog post about it with several examples: https://blog.ephorie.de/symbolic-regression-genetic-programming-or-if-kepler-had-r
Ok, so you can download rgp from the (unofficial) repository of CRAN at github.com
You should start trying the git tool to do it. This way, once you've installed it, you can clone the repository with:
git clone https://github.com/cran/rgp.git
In the R/ folder of the repository (the local copy that you've downloaded or in the very github website of the rgp package) you should see all functions of the package, as .R files.
Other way to use these functions would be to build (R CMD build) the package, install it (install.packages("builtrepo.tgz",repos=NULL,type="source")) and load (with require or include).

How to use julia package at a certain commit?

A new version of a julia package causes a problem in my project. I could use Pkg.pin to use the package at some version and I could use Pkg.checkout to use the package in a certain github branch, but how to use the package at a certain github commit? So I could find out which commit actually causes the issue in my project.
Every Julia package is just a git repo, you could always do source code management stuff using git from the command line, and use some full-featured git commands like git bisect to find out that commit.
X-ref: How to use git bisect?
To answer the original question, we can add a package at a specified commit, by specifying the commit-sha1 as follows:
(#v1.6) pkg> add Example#commitSHA1
by replacing the commitSHA1 with the commit-sha1 of the required commit of the package.
See the Pkg docs for more.

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