Skip to contents

Produces a tile map showing the field trial layout before and after padTrial() is applied.

The Before panel shows the original layout. If data is supplied this includes guard rows and any cells outside the bounding box; if data is NULL (default) the Before panel is reconstructed from the retained ("old") rows of result and gaps appear as white space where missing cells were located.

The After panel shows the padded result. Inserted cells (add == "new") are shown in light grey so they are immediately distinguishable from original plots.

Tiles are coloured by the plot-type column. When split is supplied, groups appear as columns in a facet grid with Before/After as rows, keeping Before always on top.

Usage

plot_padTrial(
  result,
  data = NULL,
  type_col = "Type",
  pattern = "Row:Column",
  split = NULL,
  label = NULL,
  theme = ggplot2::theme_bw(),
  return_data = FALSE,
  ...
)

Arguments

result

Data frame returned by padTrial(). Must contain an add column with values "old" and "new".

data

Optional original data frame passed to padTrial(). When supplied the Before panel shows the complete original layout including guard rows. When NULL (default) the Before panel is reconstructed from the "old" rows of result.

type_col

Character. Name of the plot-type column used to colour tiles. Default "Type".

pattern

Character. Colon-separated names of the row and column coordinate columns, e.g. "Row:Column". Default "Row:Column".

split

Character vector of column name(s) matching the split argument used in padTrial(). Groups appear as columns in the facet grid. Default NULL (no grouping).

label

Character or NULL. Name of a column whose values are printed as text inside each tile. NULL (default) produces no labels.

theme

A ggplot2 theme object. Default ggplot2::theme_bw().

return_data

Logical. If TRUE returns the tidy data frame used to build the plot. Default FALSE.

...

Reserved for future use.

Value

A ggplot2::ggplot object returned invisibly (extendable with +), or a data frame when return_data = TRUE.

See also

Examples

if (FALSE) { # \dontrun{
## Basic use — Before panel reconstructed from result
res <- padTrial(trial_data, split = "Block", verbose = FALSE)
plot_padTrial(res)

## Supply original data to include guard rows in Before panel
plot_padTrial(res, data = trial_data)

## Multi-block split — groups as columns
plot_padTrial(res, data = trial_data, split = "Block")

## Label each tile with the genotype name
plot_padTrial(res, label = "Geno")

## Return tidy data for bespoke customisation
df <- plot_padTrial(res, return_data = TRUE)
} # }