Skip to contents

Soft Non-numeric Occurrence Estimation (SNOE) plot

Usage

snoe_plot(
  x,
  codes = ".*",
  matchRegexAgainstPaths = TRUE,
  estimateWithin = NULL,
  title = "SNOE plot",
  vertical = FALSE,
  barWidth = 0.9,
  ggplot2Theme = ggplot2::theme_minimal(),
  greyScale = FALSE,
  colors = c("#C0C0C0", "#0072B2"),
  greyScaleColors = c("#C0C0C0", "#808080"),
  silent = rock::opts$get("silent")
)

Arguments

x

A parsed source(s) object.

codes

A regular expression to select codes to include, or, alternatively, a character vector with literal code idenfitiers.

matchRegexAgainstPaths

Whether to match the codes regular expression against the full code paths or only against the code identifier.

estimateWithin

The column specifying within what to count.

title

Title of the plot

vertical

Whether to plot horizontally (FALSE, best for reading code

barWidth

The width of the bars; can be decreased or increased, for example in combination with vertical plotting to make the plot look more like a snowy landscape.

ggplot2Theme

Can be used to specify theme elements for the plot.

greyScale

Whether to produce the plot in color (FALSE) or greyscale (TRUE).

colors, greyScaleColors

The (two) colors to use for the color and greyscale versions of the SNOE plot.

silent

Whether to be chatty or silent

Value

A list containing a ggplot2::ggplot() in the $plot slot.

Examples

### Get path to example source
examplePath <-
  system.file("extdata", package="rock");

### Get a path to one example file
exampleFile <-
  file.path(examplePath, "example-3.rock");

### Load example source
loadedExample <- rock::parse_source(exampleFile);

### Show code occurrence estimates
rock::snoe_plot(
  loadedExample
);


### Load two example sources
loadedExamples <- rock::parse_sources(
  examplePath,
  regex = "example-[34].rock"
);

rock::snoe_plot(
  loadedExamples
);


### And plotted vertically
rock::snoe_plot(
  loadedExamples,
  vertical = TRUE,
  barWidth = 1
);