Department of Biostatistics Seminar/Workshop Series

R Package Development with GitHub

Cole Beck, B.S.

Computer Systems Analyst, Department of Biostatistics

The motivation for writing an R package is to make your code available. Often this is done by contributing the package to the CRAN package repository. In this seminar we will consider an alternative method, hosting your package on GitHub and distributing via devtools. This will include a brief overview of the packages roxygen2 and testthat.

Package development cheatsheet

Prepare System

install.packages(c("devtools", "roxygen2", "testthat", "knitr")) library(devtools) has_devel()

Write Package

wd <- file.path('~','packages','miscpackage') devtools::create(wd) # modify DESCRIPTION # add code # add documentation devtools::document() # vignette VS URL # add tests devtools::use_testthat()

Additional components to consider:
  • Data
  • Compiled code

Use Git (Local)

# create local Git repository
git init
# consider adding README
# stage everything
git add .
# commit to history
git commit -m "first commit"

Use GitHub (Remote)

  1. Create user on GitHub
  2. Create new repository

# from your working directory, let local repo know about remote repo
git remote add origin
# push local to remote
git push -u origin master

Install Package

library(devtools) install_github("GitHubUserName/RepoName")

Learn more:
Topic attachments
I Attachment Action Size Date Who Comment
misc.rr misc.r manage 1.4 K 03 Dec 2014 - 10:38 ColeBeck some code to make package
Topic revision: r2 - 03 Dec 2014, ColeBeck

This site is powered by FoswikiCopyright © 2013-2022 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding Vanderbilt Biostatistics Wiki? Send feedback