An open API service indexing awesome lists of open source software.

https://github.com/trinker/pax


https://github.com/trinker/pax

Last synced: over 1 year ago
JSON representation

Awesome Lists containing this project

README

          

---
title: "pax"
date: "`r format(Sys.time(), '%d %B, %Y')`"
output:
md_document:
toc: true
---

```{r, echo=FALSE}
library("pax")
desc <- suppressWarnings(readLines("DESCRIPTION"))
regex <- "(^Version:\\s+)(\\d+\\.\\d+\\.\\d+)"
loc <- grep(regex, desc)
ver <- gsub(regex, "\\2", desc[loc])
verbad <- sprintf('Version', ver, ver)
````

```{r, echo=FALSE, message=FALSE, warning=FALSE}
library(knitr)
knit_hooks$set(htmlcap = function(before, options, envir) {
if(!before) {
paste('

',options$htmlcap,"

",sep="")
}
})
knitr::opts_knit$set(self.contained = TRUE, cache = FALSE)
knitr::opts_chunk$set(fig.path = "tools/figure/")
```

[![Project Status: Active - The project has reached a stable, usable state and is being actively developed.](http://www.repostatus.org/badges/0.1.0/active.svg)](http://www.repostatus.org/#active)
[![Build Status](https://travis-ci.org/trinker/pax.svg?branch=master)](https://travis-ci.org/trinker/pax)
[![Coverage Status](https://coveralls.io/repos/trinker/pax/badge.svg?branch=master)](https://coveralls.io/r/trinker/pax?branch=master)
[![DOI](https://zenodo.org/badge/5398/trinker/pax.svg)](http://dx.doi.org/10.5281/zenodo.15891)
`r verbad`

A gold version R package template.

pax Logo

# Description

[**pax**](http://trinker.github.io/pax_dev) is a package template system that is NOT designed to be light weight. It is the deluxe, gold version of a package template. **pax** enforces a fairly narrow package management philosophy. It expects the user will utilize:

1. [GitHub](https://github.com) for repository sharing
2. [RStudio](http://www.rstudio.com/) for GUI
3. [**testthat**](http://cran.r-project.org/web/packages/testthat/index.html) for unit testing
4. [Coveralls](https://coveralls.io/) + [**covr**](https://github.com/jimhester/covr) for code coverage rating
5. [**devtools**](http://cran.r-project.org/web/packages/devtools/index.html)/[**roxygen2**](http://cran.r-project.org/web/packages/roxygen2/index.html) for documentation
6. [**knitr**](http://yihui.name/knitr/) for README management

**pax** has one main function that does one job. `pax` (package and function named **pax**) creates a package template. It allows the user to specify construction arguments (locally or [via options in *.Rprofile*](http://www.statmethods.net/interface/customizing.html)). Arguments that can be set in the *.Rprofile* include:

| Argument | Description | Example |
|------------------|---------------------------------------------|-----------------------------------------------------|
| `name` | The user's name (first & last) | `options(name = c(first="Tyler", last="Rinker"))`| |
| `email` | The user's email address | `options(email = "tyler.rinker@gmail.com")`|
| `license` | The package license | `options(license = "GPL-2")` |
| `github.user` | The user's [GitHub](https://github.com) name | `options(github.user = "trinker")`|
| `samples` | Logical; if `TRUE`, sample *.R* & *test-.R* added | `options(samples = FALSE)` |
| `tweak` | A function or path/[url](http://goo.gl/oL7UXO) to a user specified 'tweaking' function\* | `options(tweak = "http://goo.gl/oL7UXO")`|

\****Note***: *See `?pax` for more information about the `tweak` argument; [CLICK HERE](https://raw.githubusercontent.com/trinker/pax_tweak/master/pax_tweak.R) for an example.*

These arguments can be quickly added by using the `pax_options` function. This generates the following blank script that can be added to the user's *.Rprofile*:

```{r, echo=FALSE, comment=NA}
pax_options()
```

# Template

The standard **pax** template looks like:

```
| .gitignore
| .Rbuildignore
| DESCRIPTION
| foo.rproj
| NEWS
| README.md
| README.Rmd
| travis.yml
|
+---inst
| maintenance.R
|
+---R
| foo-package.R
| sample.R
| utils.R
|
\---tests
| testthat.R
|
\---testthat
test-sample.R
```

# Installation

To download the development version of pax:

Download the [zip ball](https://github.com/trinker/pax/zipball/master) or [tar ball](https://github.com/trinker/pax/tarball/master), decompress and run `R CMD INSTALL` on it, or use the **pacman** package to install the development version:

```r
if (!require("pacman")) install.packages("pacman")
pacman::p_load_current_gh("trinker/pax")
```
# Additional Features

| Function | Description |
|----------------|-----------------|
| `new_r` | Makes **roxygen2** style *.R* template file from a `function` or character string |
| `new_test` | Makes **testthat** style unit test template file from a `function` or character string |
| `new_r_test` | Makes **roxygen2** style *.R* and **testthat** style unit test files from a `function` or character string |
| `new_data` | Adds data & appends **roxygen2** style template to package description *.R* file |
| `new_vignette` | Makes **rmarkdown** style *.Rmd* vignette template file |

In addition to the `pax` templating function, **pax** also has a few additional tools to generate *.R* and *test-____.R* scripts that add a **roxygen2** style *.R* file to the *R* directory as well as adding a **testthat** style unit test file to *tests/testthat* directory. These actions can be done separately but it is recommended that they be combined into one function call: `new_r_test`. This sets a [test-driven development](http://en.wikipedia.org/wiki/Test-driven_development) expectation that as a function is created a unit test is used in the development process.

The `new_data` enables the user to add a data set to the *data* directory and append the **roxygen2** style *.R* markup template to the package's description file (*R/____-package.R*). The `new_vignette` function provides a means of quickly adding an [**rmarkdown**](http://rmarkdown.rstudio.com/package_vignette_format.html) with the appropriate `title` field and `\VignetteIndexEntry` set.

# Help

- [HTML Vignette: Introduction to pax](http://trinker.github.io/pax/vignettes/introduction.html)

# Additional Package Development Resources

- [Writing R Extensions](http://cran.r-project.org/doc/manuals/r-release/R-exts.html)
- [RStudio Package Development Cheat Sheet](http://www.rstudio.com/wp-content/uploads/2015/03/devtools-cheatsheet.pdf)
- [R packages by Hadley Wickham](http://r-pkgs.had.co.nz/)

# Contact

You are welcome to:
* submit suggestions and bug-reports at:
* send a pull request on:
* compose a friendly e-mail to: