https://github.com/jansim/nicknames
Specify human readable names for the columns in your data once and then reuse them across your project to rename plots axes, dataframe columns, tables and anything else.
https://github.com/jansim/nicknames
data-cleaning data-visualization r r-package
Last synced: 10 months ago
JSON representation
Specify human readable names for the columns in your data once and then reuse them across your project to rename plots axes, dataframe columns, tables and anything else.
- Host: GitHub
- URL: https://github.com/jansim/nicknames
- Owner: jansim
- License: other
- Created: 2025-08-13T18:45:28.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2025-08-25T16:55:10.000Z (10 months ago)
- Last Synced: 2025-08-25T18:09:07.665Z (10 months ago)
- Topics: data-cleaning, data-visualization, r, r-package
- Language: R
- Homepage: http://simson.io/nicknames/
- Size: 3.38 MB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.Rmd
- License: LICENSE
Awesome Lists containing this project
README
---
output: github_document
---
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# nicknames 
[](https://github.com/jansim/nicknames/actions/workflows/R-CMD-check.yaml)
Nicknames allows you to specify human readable names for the columns in your data once and then reuse them across your project to rename plots axes, dataframe columns, tables and anything else.
## Installation
You can install the development version of nicknames from [GitHub](https://github.com/) with:
``` r
# install.packages("pak")
pak::pak("jansim/nicknames")
```
## Example
With nicknames, you can register the mapping between columns in your data and human readable column names once and easily re-use them everywhere.
```{r ex-setup}
library(nicknames)
nn_register(c(
"mpg" = "Miles per Gallon",
"hp" = "Horsepower",
"cyl" = "Number of\nCylinders"
))
```
Including ggplot2 plots...
```{r ex-ggplot, fig.height=3, fig.width=7}
library(ggplot2)
# Create plot and apply nickname labels
ggplot(mtcars, aes(x = mpg, y = hp, color = factor(cyl))) +
geom_point() +
labs_nn()
```
...dataframes...
```{r ex-df, message=FALSE}
library(dplyr)
mtcars |>
select(mpg, hp, cyl) |>
nn() |>
head()
```
...and column names directly.
```{r ex-char}
nn("mpg")
```
While variables names are extracted from within function calls (e.g. `factor(cyl)` above), more exact matches take priority if you need to be precise.
```{r ex-ggplot-exact, fig.height=3, fig.width=7}
nn_register(c(
"factor(cyl)" = "Number of\nCylinders (factor)"
))
ggplot(mtcars, aes(x = mpg, y = hp, color = factor(cyl))) +
geom_point() +
labs_nn()
```