commit
s allow you to take a “snapshot” relative to new lines, modified lines, and deleted linespush/pull
sends the snap shots on your computer to github or brings the snap shots from github to your computer (respectively)“… from user to programmer to contributor, in the gradual progress that R encourages.”
~ John Chambers (Software for Data Analysis: Programming with R)
devtools
/ usethis
can facilitate this process.libPaths()
library()
function.library(tidyverse)
search()
## [1] ".GlobalEnv" "package:forcats" "package:stringr"
## [4] "package:dplyr" "package:purrr" "package:readr"
## [7] "package:tidyr" "package:tibble" "package:ggplot2"
## [10] "package:tidyverse" "package:stats" "package:graphics"
## [13] "package:grDevices" "package:utils" "package:datasets"
## [16] "package:methods" "Autoloads" "package:base"
R provides tools (R CMD INSTALL, R CMD BUILD, R CMD CHECK
, etc…) to move to different stages
library(devtools)
library(usethis)
# documentation
library(roxygen2)
# tests
library(testthat)
devtools
and usethis
allows us to get our package up an running“The goal of devtools is to make package development as painless as possible”
~ Hadley Wickham (R Packages)
install.packages("devtools")
library("devtools")
usethis
focuses on automating repetitive tasks in building packages install.packages("usethis")
library("usethis")
“usethis is a workflow package: it automates repetitive tasks that arise during project setup and development, both for R packages and non-package projects.”
~ usethis
package description
Just like in the version control we are going to us the “Github First” Approach. Here are the reminder of the steps:
In GitHub, do the following:
go to the top-level directory (i.e., github.com/<your user name>)
click on “+” at top right, and select “New repository”
name the repository (e.g., “tartan”)
provide a short description of the repository (don’t leave completely blank!)
keep the repository public (as students you have access to free private repos https://education.github.com/pack, but for purposes of this lab keep the repo public)
click on “Initialize this repository with a README” and select the R option in “Add .gitignore”… there is no need to “Add a license”
click on “Create Repository”
…then RStudio
In RStudio, do the following:
click on File > New Project…
click on “Version Control”, then on “Git”
provide the full address for the “Repository URL” (including the https, etc.; by default, this will provide the name of your local repository)
make sure “Create project as subdirectory of:” points to where you want to point it
click on “Create Project” (in this example we will be calling our package tartan
)
An R (source) package is just files in a directory, formatted in a specific way.
To create the bare bones R package, just type:
usethis::create_package("tartan")
tartan
project, may need to do setwd("../")
, run the above line and then do setwd("tartan")
.This should give us:
R/
man/
NAMESPACE
fileDESCRIPTION
filetartan.Rproj
file (if using RStudio)and anything else you included from intializing your git repo (.gitignore
, LICENSE
, etc)