pkg_name = "usethis" # pkg_name = "devtools"
I use RStudio. I do File → New Project → New Directory → R Package
and I make sure "Create a git repository" is clicked. I don't use packrat
for my packages, so that is not clicked.
Things to do:
R/hello.R
man/hello.Rd
Build → Configure Build Tools → Generate Documentation with Roxygen
, make sure that's clicked. I click Vignettes
and Build and Reload
. --as-cran
under the "Check options" in Build → Configure Build Tools
.NAMESPACE
file. If building fails, add an empty file with # Generated by roxygen2: do not edit by hand
at the top and rerun.I add this to the DESCRIPTION
file:
Authors@R: person(given = "John", family = "Muschelli", role = "cre", email = "muschellij2@gmail.com")
I use Authors@R
even if there is only one author because of the desc
package issue and that package is relied upon for site building and stuff later.
Maintainer: John Muschelli <muschellij2@gmail.com>
I am explicit about Maintainer
because some people use that field as some parsers use Author
and not Authors@R
.
I use License: GPL-2
.
Change the Title
so that it's Title Case and make sure to put single quotes around weird words (like science-specific).
Change the Description
so that it's a sentence and it ends with a period. Also I keep putting single quotes around weird words (like science-specific). Make sure to put links in angle brackets (<http...>
). Use DOIs if you can. If you go too long on a line, indent it with 4 spaces "".
I run the short version of the code on http://johnmuschelli.com/neuroc/getting_ready_for_submission/index.html, which essentially to run (in R):
`r pkg_name`::use_git() `r pkg_name`::use_github() # must have GITHUB_PAT set up `r pkg_name`::use_readme_md() `r pkg_name`::use_vignette("my-vignette") `r pkg_name`::use_testthat() `r pkg_name`::use_appveyor() `r pkg_name`::use_travis()
And edit the following files:
.travis.yml
Add the following lines:
warnings_are_errors: true after_success: - Rscript -e 'covr::coveralls(type = "all")'
to .travis.yml
.
appveyor.yml
Add the following lines:
environment: global: WARNINGS_ARE_ERRORS: 1
to appveyor.yml
.
README.md
Add the following lines, changing GITHUB_USERNAME/REPO
to the correct version
[![Travis-CI Build Status] (https://travis-ci.org/GITHUB_USERNAME/REPO.svg?branch=master)] (https://travis-ci.org/GITHUB_USERNAME/REPO) [![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/github/GITHUB_USERNAME/REPO?branch=master&svg=true)](https://ci.appveyor.com/project/GITHUB_USERNAME/REPO)
to the README.md
.
I tend to add to the README.md
an installation script (using remotes
or devtools
) :
## Installation To install the package, please run: ```r remotes::install_github("GITHUB_USERNAME/REPO") ```
I grab my Description
field from DESCRIPTION
file and add The package DESCRIPTION_FIELD_HERE
in README.md
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.