gglabeller: gglabeller

Description Usage Arguments Details Value Author(s) Examples

View source: R/gglabeller.R

Description

Shiny gadget for selecting points to label in a ggplot object

Usage

1
2
gglabeller(gg, mapping = gg$mapping, data = gg$data, geom = c("text",
  "label"), ..., width = "100%", height = "100%")

Arguments

gg

ggplot object

mapping

aesthetics mapping, from aes

data

data.frame with data for plotting

geom

geom to use – "text" or "label"

...

additional arguments to pass to geom_text_repel or geom_label_repel

width

width of plot, as percent or pixels

height

height of plot, as percent or pixels

Details

Click on a point or brush over a set of points to label them. Clicking on a labelled point or brushing over a set of points that are all labelled will remove the labels. Brushing over some points that are labelled and some that are not will add labels to the ones that are not.

gglabeller sses ggrepel for controlling the position of labels. The parameters tab can be used to adjust ggrepel parameters.

Value

Upon clicking the "Done" button, the gadget returns a list with three elements:

plot

The plot itself

ix

The indices of the rows of the data used for labelling

code

a character vector with a code snippet for recreating the plot reproducibly

Author(s)

Alicia Schep

Examples

1
2
3
4
5
6
7
if (interactive()){

  p <- ggplot(mtcars, aes(x = wt, y = mpg)) + geom_point()

  plabelled <- gglabeller(p, mapping = aes(label = rownames(mtcars)))

}

AliciaSchep/gglabeller documentation built on March 2, 2021, 7:18 p.m.