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
- Host: GitHub
- URL: https://github.com/goldingn/default
- Owner: goldingn
- License: other
- Created: 2017-08-04T01:49:43.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-08-07T07:29:52.000Z (over 7 years ago)
- Last Synced: 2025-03-18T01:11:14.251Z (about 1 month ago)
- Language: R
- Size: 208 KB
- Stars: 45
- Watchers: 1
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.Rmd
- License: LICENSE
Awesome Lists containing this project
- jimsghstars - goldingn/default - change the default arguments in R functions (R)
README
---
output:
md_document:
variant: markdown_github
---[](https://travis-ci.org/goldingn/default)
[](https://codecov.io/github/goldingn/default?branch=master)
[](https://cran.rstudio.com/web/packages/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)
```