easy_labs: Easily add ggplot labels using label attribute of...

View source: R/labs2.R

easy_labsR Documentation

Easily add ggplot labels using label attribute of 'data.frame' column

Description

Applies same logic as labs but uses as default the column label attribute if present as the variable label in the plot.

Usage

easy_labs(..., teach = FALSE)

Arguments

...

A list of new name-value pairs. The name should either be an aesthetic, or one of "title", "subtitle", or "caption"

teach

print longer equivalent ggplot2 expression?

Examples


iris_labs <- iris

lbl <- c('Sepal Length', 'Sepal Width', 'Petal Length', 'Petal Width', 'Flower Species')

labelled::var_label(iris_labs) <- split(lbl,names(iris_labs))

p <- ggplot2::ggplot(iris_labs,ggplot2::aes(x=Sepal.Length,y=Sepal.Width))+
  ggplot2::geom_line(ggplot2::aes(colour=Species))

p

p + easy_labs()
p + easy_labs(title = "Plot Title", subtitle = 'Plot Subtitle', x = 'x axis label')

p + easy_labs(teach = TRUE)


ggeasy documentation built on Nov. 3, 2024, 9:08 a.m.