Skip to contents

R6 class for plotting Turf objects. Can be used directly from the Turf class by calling the $plot accessor.

Methods


Method new()

Initialize with a TurfPlotter object

Usage

TurfPlotter$new(turf)

Arguments

turf

A Turf object (from the Turf R6 class)


Method incremental_plot()

Plot Incremental Reach

Visualizes how reach improves as more items are added to the TURF combination set. This is useful to assess the diminishing returns of adding more items. The function plots the top combination (by reach, or by reach then frequency if available) at each combination size.

Usage

TurfPlotter$incremental_plot(
  metric,
  point_size = 25,
  text_size = 6,
  point_color = "#50bd90",
  line_color = "#cccccc",
  add_frequency = FALSE
)

Arguments

metric

A character string indicating which reach metric to plot. Must match one of the metrics computed in the associated Turf object.

point_size

A numeric scalar controlling the size of points in the plot. Default is 25.

text_size

A numeric scalar controlling the font size of percentage labels. Default is 6.

point_color

Plot colour of plot. A valid colour.

line_color

Line colour of plot. A valid colour.

add_frequency

A logical flag indicating whether to show frequency values below each point. Not supported for weighted_reach. Default is FALSE.

Returns

A ggplot object showing incremental reach across combination sizes.


Method topN_plot()

Plot TURF combinations

When a combination has been selected, plot top N combinations by reach.

Usage

TurfPlotter$topN_plot(
  metric,
  n_item,
  top_n = 3,
  color_palette = NULL,
  wrap_length = 60,
  ...
)

Arguments

metric

Metric to plot reach from?

n_item

Combination size to plot

top_n

Top N combinations to plot

color_palette

Optional palette (named vector or dataframe)

wrap_length

Label wrap length

...

Extra arguments to be used in g6tr.theme::g6tr_bar_plot()

Returns

ggplot object


Method clone()

The objects of this class are cloneable with this method.

Usage

TurfPlotter$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.