-
Notifications
You must be signed in to change notification settings - Fork 0
Session 4 guide
Selin Jessa edited this page May 14, 2020
·
12 revisions
- 30 min: discussion, debugging, tour various build issues
- 10 min: Intro to dependencies, DESCRIPTION, NAMESPACE, and examples
- 5 min: Review the whole workflow, and merge
develop-private
tomaster-private
to close issues - 10 min: Demo of adding a dependency
- In this task, we'll run through the whole contribution workflow again, but this time, we'll be each adding a function that has an external dependency. The idea is to practice the whole branch-change-commit-rebase workflow.
- Again, we'll then open a PR from our issue branch to
develop-private
, and ensure our code passes status checks & reviews before integrating it. - In terms of choosing what to add, I suggest to start with a very small package where you need just a single function, so for now please avoid:
dplyr
,tidyverse
,tidyr
,purrr
,ggplot2
,magrittr
. Instead, some suggestions: something fromprcomp
,stats
,glue
,hclust
,utils
, etc... - The package now contains a new dataset, called
fibonacci_mat
, which is a matrix that you could use to perform some computation
At this point, we'll generally assume everyone has created a function with tests, and that it is now merged into
the codebase (master-private
), and the issue closed. If not, you can easily start this task independently from the previous issue!
- Open a new issue specifying what you'll be adding -- make sure the package name is in the issue title, so other people can see
- Create a new branch
- First, ensure your local repository is up to date: while on
develop-private
, pull any changes from GitHub -
While still on the
develop-private
branch, create a new branch, corresponding to your new issue
- First, ensure your local repository is up to date: while on
- Add your contribution for today's task, by creating a new function which uses a function from an
external package available on CRAN. You will need to:
- Add the package as a dependency in DESCRIPTION
- Import the desired function with an
@importFrom pkg function
statement in your function's documentation - Document the function
- Create some unit tests for the function
- Optional: this time, you may want to explore using the two functions
usethis::use_r("myfunction")
andusethis::use_test("myfunction")
to create the file templates for you!
- When you've finished, commit & push your changes, and once Travis status checks pass, open a pull request from your issue branch onto the
develop-private
branch. In the PR message, add "This closes #XXX" to reference your issue - If anybody has made changes to the
develop-private
branch in between your commits to your branch, don't forget to rebase regularly onto develop private:- Get the latest changes on the
develop-private
branch:git checkout develop-private
thengit pull
- Go back to your issue branch,
git checkout issue/XXX
- Rebase:
git rebase develop-private
- Get the latest changes on the
✨ Keep in mind our workflow from previous sessions - you'll need to...
- ...follow the steps from Session 1 to create and document a function
- ...follow the steps from Session 2 to create a test for it
- ...follow the steps from Session 3 to push your changes, and run through the debugging cycle until the Travis status checks pass
- Great book on Git/GitHub specifically for R users! https://happygitwithr.com/git-intro.html
- Evolved version of the R packages book, with great examples and explanations: https://r-pkgs.org/