normalize_axes_labels: A function to make nice axes lables for ggplot.

Description Usage Arguments Details Value Examples

View source: R/helper_functions.R

Description

The function will insert new lines symbol (\n) replacing "_", ".", and before "(", so that long labels can be displayed on multiple lines

Usage

1

Arguments

s

vector of labels to be normalized

revert

if FALSE, the symbols _,.,( are replaced with new lines. If TRUE, the operation is reverted; see "Details"

Details

Literally undoing the normalization is obviously not possible, since there is no way of knowing which symbols were replaced with nelines. Thus, the newlines not adjacent to "(" are replaced with "_"; the newlines preceding "(" are just deleted.

Value

vector of normalized labels if revert = FALSE; vector of labels without newlines if revert = TRUE

Examples

1
2
3
labels <- c("critical_region", "spillover.region", "region(another)")
normalize_axes_labels(labels)
# [1] "critical\nregion"  "spillover\nregion" "region\n(another)"

antonmalko/ettools documentation built on May 28, 2019, 3:35 p.m.