The packageSkeletonForR is both a GitHub version control repository, and associated GitHub hosted static website as well as an R package. The combination of GitHub and R together is a super-power skill to develop if you have a serious interest in data analysis.
The following steps are meant to help you get set up:
You’ll need to have software installed and access to GitHub to make all of this work.
update.packages(ask=FALSE)
install.packages("devtools")
devtools::install_github("centerforassessment/packagePages")
devtools::install_github("centerforassessment/centerPackageTemplate")
The contents of this repo need to be cloned to your local computer/device. This is done by cloning the repo. Don’t fork the repo as you won’t be contributing to this package skeleton (at least I don’t expect you will — however that’s OK too) but instead will be using this as a starting point to create your own customzed R package/GitHub repo that will, ideally, be quite different.
Go to your personal (or institutional) GitHub page, look for the repositories
tab and click on the new
button to start creating a new repo that will house the source code for your R package. Here’s a screenshot from my initial setup:
The packageSkeletonForR package is a super simple R package that contains just two functions for illustration purposes: strHead
and strTail
. These two functions take the first n characters of the head or tail of a character string (or a vector of character strings), respectively. They are the analogs of the R functions head
and tail
but for strings. You’re welcome to keep these functions or remove them.
Some things you should do:
packageSkeletonForR
to something you want (in these instructions we’ll call is myPackageName
). Throughout the package change any occurrence of packageSkeletonForR
to the name you pick.NAMESPACE
(export the function) and document the function in the man
(manual) folder. Examine the current NAMESPACE
and man
folder contents to see how that is done.NEWS.md
and NEWS
files indicating changes to the package. NEWS.md is used for the static website and, ideally, will just be a copy of NEWS
.vignettes
folder. Use the basic vignette (packageSkeletonForR.Rmd
) in the folder as a starter.DESCRIPTION
, inst/CITATION
, man/packageSkeletonForR.Rmd
(last file should be named the package name you picked).To make sure everything is working (be prepared to have some things not work) build your package locally. If you’re using RStudio, there are capabilities to build the package embedded into the user interface. If you are using
You’ll need to create a GitHub repo in your account for myPackageName
.
GitHub is rapidly evolving into much more than a website to do version control. For each repo, one can set up:
Another huge benefit of using GitHub to build your package is that you can immediately share your package with others without necessarily posting the package to CRAN. packageSkeletonForR is a functional R package and can be installed from GitHub just like any other R package via:
devtools::install_github("CenterForAssessment/packageSkeletonForR")
or
remotes::install_github("CenterForAssessment/packageSkeletonForR")
Once you get the package set up in your own repository, your package will be able to be installed similarly. In our work we have functional development versions of the package available via GitHub and periodically post a big release version on CRAN just to keep that up-to-date.
The packageSkeletonForR Package is crafted with :heart: by:
I love feedback and am happy to answer questions. Feel free to clone and make a pull request with the specifications for other languages.