plotDetectionBoxplot: Plot Detection Boxplot

View source: R/plotDetectionBoxplot.R

plotDetectionBoxplotR Documentation

Plot Detection Boxplot

Description

Plots time series of boxplots showing detection data across time

Usage

plotDetectionBoxplot(
  x,
  group = "species",
  facet = NULL,
  color = hue_pal(),
  bin = "day/week",
  combineYears = FALSE,
  effort = NULL,
  dropZeroes = FALSE,
  returnData = FALSE
)

Arguments

x

dataframe of detection data read in with loadDetectionData

group

name(s) of columns indicating which rows of x are distinct from each other, typically something like "site" or "species" or both. These are used to define the different data points that go in to each boxplot, see Details below for more information.

facet

if not NULL, name of the column in x to facet the plot by

color

only used if facet is not NULL, colors to use for each separate facet. Can either be a color palette function or a character vector of color names. If a vector, it can be named by the levels in facet that each color should correspond to

bin

time bins to use for generating plot, must be a character of format "time1/time2" where "time1" will be the y-axis of the plot and "time2" will be the x-axis of the plot. Times are one of "hour", "day", "week", or "month" (e.g. "day/week").

combineYears

logical flag to combine all observations to display as a single "year"

effort

if not NULL, a dataframe describing on effort times to be formatted with formatEffort. If effort data is not provided then times with zero detections will not be properly accounted for.

dropZeroes

logical flag to remove boxplots where all observations are zero (these would normally appear as a flat line at zero)

returnData

if TRUE then no plot will be generated, instead the dataframe that would normally be used to make the plot will be returned

Details

The combination of group, facet, and combineYears determine the data points that make up each boxplot. If combineYears=TRUE, then there will be a different point for each year. There will additionally be separate points for each different value of the columns in group, excluding the column used for facet (since these points are instead split out to different facetted plots).

For example, if you have data from a single location, then settings of combineYears=FALSE, group='species', and facet=NULL will create a plot where each point in a boxplot represents the number of detections for a species. If you change to facet='species', then the result will show a multi panel plot where each boxplot is just a single point. Then changing to combineYears=TRUE will show a multi panel plot where each point in a boxplot is the number of detections for that panel's species in different years.

Value

a ggplot object

Author(s)

Taiki Sakai taiki.sakai@noaa.gov


PAMscapes documentation built on April 4, 2025, 2:17 a.m.