Plot_Size_Frequency: Plot Size Frequency Distributions

Description Usage Arguments Value Examples

View source: R/Plot_Size_Frequency.R

Description

Plot Size Frequency Distributions

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
Plot_Size_Frequency(
  data,
  size.metric,
  log_size = FALSE,
  nbins = 15,
  group_by = FALSE,
  fill_by = FALSE,
  facetRow_by = FALSE,
  facetCol_by = FALSE,
  scales_gg = "free"
)

Arguments

data

a dataframe of calibrated size metrics, that includes user defined variables based on 1) the directory structure, and 2) the full ROI labels used in image analyses. As output from Full_SizeExtractR_Workflow, with calibration lengths not included

size.metric

character vector of length 1. Input the name of the size metric of interest. Must be an element of colnames(data). Case sensitive.

log_size

logical. Whether to log transform the size metric or not.

nbins

the number of bins to show on the histogram

group_by

Set the grouping variable(s). character vector of length 1, 2 or 3, depending on the number of categorical grouping variables. Input the name of the variables c(). Case Sensitive. If no grouping variable is wanted, then leave empty.

fill_by

Set the fill and colour variable. character vector of length 1. Input the name of the variable. Case Sensitive. If no grouping variable is wanted, then leave empty.

facetRow_by

Set the facet row variable. character vector of length 1. Input the name of the variable. Case Sensitive. If no grouping variable is wanted, then leave empty.

facetCol_by

Set the facet row column variable. character vector of length 1. Input the name of the variable. Case Sensitive. If no grouping variable is wanted, then leave empty.

scales_gg

set facet variable of ggplot2::facet_wrap(). Either "free", "free_x", "free_y", or "fixed"

Value

Returns a ggplot object showing histograms of any size metric, by grouping variable, coupled with probability density curves scaled to the maximum histogram count per group.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
# load a dataset with three grouping variables: Year, Site, and Transect
data(Database.groups)

# Make a plot with histograms by three groups
Plot_Size_Frequency(data = Database.groups,
                    size.metric = "Area",
                    log_size = TRUE,
                    nbins = 20,
                    group_by = c("Year","Site","Transect"),
                    fill_by = "Transect",
                    facetRow_by = "Site",
                    facetCol_by = "Year",
                    scales_gg = "fixed")

liamlachs/SizeExtractR documentation built on Feb. 13, 2022, 9:46 p.m.