-
Notifications
You must be signed in to change notification settings - Fork 4
Using the Template
There's a shortcut to this, which is provided here for people short on time, but the scenic route follows.
Github command line client
Install the Github command line client gh
following the instructions for your OS here: https://github.com/cli/cli.
Run gh auth login
to link your device with your Github account the first time you use the CLI.
Once installed and authenticated, run:
gh repo create epiverse-trace/mypackage --public --template=epiverse-trace/packagetemplate
Clone the repository as usual using your preferred method.
Rscript -e 'devtools::create("mypackage")'
or
Rscript -e 'usethis::create_package("mypackage")'
cd mypackage
git init
Github command line client
Install the Github command line client gh
following the instructions for your OS here: https://github.com/cli/cli.
Run gh auth login
to link your device with your Github account the first time you use the CLI.
Create the package repository in the Epiverse TRACE organisation.
# still in mypackage
gh repo create epiverse-trace/mypackage
git push --set-upstream origin main
Getting R.gitignore
from https://github.com/github/gitignore, and renaming it to .gitignore
.
wget
is cross platform and should be available on most systems. Alternatives using curl
exist.
wget https://raw.githubusercontent.com/github/gitignore/main/R.gitignore
mv R.gitignore .gitignore
These next steps are from the R command line.
If you are prompted to copy or edit text in the terminal (especially if you launched R from the terminal using $ R
), you might be in Vim. Exit by typing :wq
, and edit these files in a text editor.
- Populate fields in the DESCRIPTION and NAMESPACE
# e.g. using data.table
usethis::use_package("data.table")
Actually data.table
requires a bit more configuration to use many of its features, such as :=
and .SD
. Use instead:
usethis::use_data_table()
- Set up unit testing infrastructure
usethis::use_testthat()
# and a basic test file
usethis::use_test("basic-test")
# code coverage YAML for codecov
usethis::use_coverage("codecov")
- Set a licence
We prefer the MIT licence, primarily because it is short and easy to read.
usethis::use_mit_licence()
- Make a README page
usethis::use_readme_rmd()
Readme.md can be updated manually from the Readme.Rmd created above, using
devtools::build_readme()
or using a Github Actions setup (see the examples here https://github.com/r-lib/actions/tree/v2-branch/examples).
- Set up continuous integration using Github Actions
# to check package installation
usethis::use_github_actions_check_standard()
# to report code coverage results to codecov
usethis::use_github_action("test-coverage")
- Set up documentation
a. Document the package as required using
devtools::document()
b. Set up a pkgdown
website.
# configure the pkgdown YAML.
# can be saved and edited later
usethis::use_pkgdown()
# build the website using
pkgdown::build_site()
Or set up a Github Actions job using usethis::use_github_action("pkgdown")
.