|
| 1 | +# Creating an R package |
| 2 | +How to create an R package for the bican-mccarroll-manuscript1 repository. |
| 3 | + |
| 4 | +## Creating a package using RStudio |
| 5 | + |
| 6 | +1. Get started with github and create a branch using the [basic github workflow](https://docs.google.com/document/d/1A5T8ZVhNxP0GCQmmo1R8qaPPXah9cvSLI96U3TZdYos/edit?tab=t.0) |
| 7 | +1. In RStudio, go to `File` -> `New Project...` |
| 8 | +1. Pick `New Directory` |
| 9 | +1. Pick `R Package` |
| 10 | +1. Give your package a name that starts with `bican.mccarroll.` (e.g., `bican.mccarroll.frob`) |
| 11 | +1. Create the project as a subdirectory `<your-git-sandbox>/bican-mccarroll-manuscript1/R` |
| 12 | +1. Set up github actions for your package by copying two workflow files (replace `frob` with your package name): |
| 13 | + - `cp .github/workflow-templates/R-package.yml .github/workflows/R-frob.yml` |
| 14 | + - `cp .github/workflow-templates/roxygen.yml .github/workflows/roxygen-frob.yml` |
| 15 | +1. Edit these two files and replace `<package_name>` with your package name |
| 16 | +1. Do your package development as usual, including adding documentation using roxygen2. |
| 17 | +1. When you are ready to commit your changes, use the [basic github workflow](https://docs.google.com/document/d/1A5T8ZVhNxP0GCQmmo1R8qaPPXah9cvSLI96U3TZdYos/edit?tab=t.0) to commit and push your changes. |
| 18 | + |
| 19 | +Note that for now we are requiring review before PRs. We can change if this is cumbersome. |
| 20 | + |
| 21 | +Note also that the github actions are not active until they are merged into the main branch, so they won't run |
| 22 | +until they have been merged. Subsequent PRs will trigger the R cmd check action. |
| 23 | + |
| 24 | +## Generating documentation via github actions |
| 25 | +You can cause roxygen2 to run via github action by creating a PR, and then commenting on the PR |
| 26 | +with `/document.<package_name>`, e.g. `/document.frob`. This will trigger the roxygen action, which will generate the |
| 27 | +documentation. It's kinda weird, because it's not obvious that the action is running, but |
| 28 | +you can see the action in the Actions tab of the repository, and eventually you'll see a new commit added to your branch. |
| 29 | +Note also that if you want to add more commits to the branch after the action has run, you should `git pull` the |
| 30 | +changes that were added to your branch by the action, otherwise you will get a merge conflict |
| 31 | +when you try to push your changes. |
| 32 | + |
| 33 | +This doesn't work all that well, so it may be easier just to generate documentation and NAMESPACE |
| 34 | +locally, and then commit the changes to the branch. |
0 commit comments