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

https://github.com/goldingn/default

change the default arguments in R functions
https://github.com/goldingn/default

Last synced: about 1 month ago
JSON representation

change the default arguments in R functions

Awesome Lists containing this project

README

        

---
output:
md_document:
variant: markdown_github
---

[![build status](https://travis-ci.org/goldingn/default.svg?branch=master)](https://travis-ci.org/goldingn/default)
[![codecov.io](https://codecov.io/github/goldingn/default/coverage.svg?branch=master)](https://codecov.io/github/goldingn/default?branch=master)
[![cran version](http://www.r-pkg.org/badges/version/default)](https://cran.rstudio.com/web/packages/default)
[![cran downloads](http://cranlogs.r-pkg.org/badges/default)](http://cran.rstudio.com/web/packages/default/index.html)

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE, cache = FALSE, fig.height=3, fig.width=4)
set.seed(1)
```

# default
### change the default arguments in R functions.

Tired of always typing out the same old arguments to functions? Use `default()` to set your favourite arguments as the defaults.

### Example:

```{r load, eval = FALSE}
install.packages("default")
library(default)
```
```{r load_secret, echo = FALSE}
library (default)
```

##### boring old defaults

```{r boring}
hist(iris$Sepal.Width)
```

##### exciting new defaults

```{r exciting}
default(hist.default) <- list(col = "deeppink", border = "white", ylab = "", main = "")
```

```{r exciting_plot}
hist(iris$Sepal.Width)
```

##### you can still change the arguments

```{r change}
hist(iris$Sepal.Width, col = "limegreen")
```

##### and restore the original defaults

```{r restore}
hist.default <- reset_default(hist.default)
hist(iris$Sepal.Width)
```