R & GitHub Good Practices
Gábor Csárdi
R & GitHub Good Practices
What is CI?

Login with GitHub
Add a repository
Choose repository to add
Build history (empty)
Build history
Build output
Set up Travis for an R package
1. Create .travis.yml
file:
language: R
sudo: false
cache: packages
2. Add it to the repository
3. Omit it from the R package, create .Rbuildignore
:
^\.travis\.yml$
4. Commit and push
Add a README.md
file, and a badge:
[]
(https://travis-ci.org/<user>/<repo>)

Exercises
2. Turn on Travis for your repository
3. Add a .travis.yml
file to your repository
4. Push the new version to GitHub
5. Add a badge to your README.md
file
What is test coverage?
Code coverage is a measure of the amount of code being exercised by the tests. It is an indirect measure of test quality.
Jim Hester, covr
package author
Set up test coverage runs on Travis
Extend your .travis.yml
file:
...
r_github_packages:
- jimhester/covr
warnings_are_errors: true
notifications:
email:
on_success: change
on_failure: change
after_success:
- Rscript -e 'covr::codecov()'
Exercises
1. Add (dummy?) tests to your repository
2. Add code coverage support on Travis
3. Push the new version to GitHub
4. Add a badge for code coverage to README.md
Good Practices
for R packages
Tests
README.md
file
NEWS.md
file
Value busy maintainers’ time
- No +1 comments or Thank you! comments.
- Do not submit large pull requests without asking first.
- Comply with the repo standards. Really, do what the owner says.
- Don’t be upset if
- your issue is not answered
- your PR is ignored
- you are told to change your PR
- your PR is rejected
- Friendly reminder comments are OK (private emails not!)
Not just code
- git & GitHub are great for R Markdown
- Data analysis, presentations, etc.
- Scientific articles (not in word)
- Anything that is text, really: see e.g. Awesome R
Pain points
- If something goes wrong, it will be hard to fix it. Just don’t tinker with the history. If you do, always make backups first.
- No code review tools with R support
- No multi-platform continuous integration support
- R package GitHub repo is also for distribution: auto-generated files are in the repository, diffs are bloated.
- Price