imed_plot: Publication-oriented abundance/distribution figure

View source: R/figures.R

imed_plotR Documentation

Publication-oriented abundance/distribution figure

Description

Publication-oriented abundance/distribution figure

Usage

imed_plot(
  x,
  xvar = NULL,
  value = "Mean",
  type = c("box", "violin", "scatter", "histogram"),
  guard = TRUE
)

Arguments

x

An 'imed_db', or a measurement-level data frame such as the output of 'imed_analysis_set()'. The comparability guard is applied, so the records must belong to one compatible comparability class.

xvar

Field to place on the x axis (unquoted or quoted name). Required for the box, violin and scatter types.

value

Name of the numeric measurement field to plot (default '"Mean"').

type

Plot type: '"box"', '"violin"', '"scatter"' or '"histogram"'.

guard

If 'TRUE' (default), stop when the records fail the comparability check.

Value

A 'ggplot' object that can be printed, modified with further 'ggplot2' layers or saved with 'imed_export_figure()'.

Examples

toy <- data.frame(
  Study_ID = paste0("S", 1:12),
  Comparability_Class = "CLASS_A",
  Reported_Unit = "items/L",
  Metric_Type = "Abundance",
  Strict_Synthesis_Eligibility = "YES",
  Group = rep(c("g1", "g2"), 6),
  Mean = c(2.1, 3.4, 1.8, 4.0, 2.9, 3.1, 2.4, 3.8, 1.9, 3.3, 2.7, 4.2),
  SD = rep(c(0.6, 0.9), 6),
  N = rep(c(10, 12, 8), 4)
)
imed_plot(toy, xvar = "Group", type = "box")
imed_plot(toy, type = "histogram")

imedR documentation built on Nov. 3, 2026, 5:08 p.m.