trafficLightPlot: Traffic light plots for time series data

View source: R/trafficLightPlot.R

trafficLightPlotR Documentation

Traffic light plots for time series data

Description

This function produces a traffic light plot for visualizing trends in multiple time series. The input file is a data frame with a series of time steps and data values at those time steps. Time series data are automatically sorted within the plot based on an ordination analysis, such that those displaying similar trends appear more closely together.

Usage

trafficLightPlot(
  dataset,
  columns = NA,
  mintime = NA,
  maxtime = NA,
  noNAs = 0,
  splits = 5,
  cexlabs = 0.9,
  indatformat = "%Y",
  outdatformat = "%Y",
  graycol = FALSE,
  method = "pca",
  PC = 1
)

Arguments

dataset

A data.frame in which the first column is numerical values representing time steps and subsequent columsn are data values at those time steps.

columns

an integer or integer list defining the column numbers of data to be included. Defaults to the entire data set.

mintime

a value representing the earliest time step to be included in the analysis. Defaults to first time step in data set.

maxtime

a value representing the last time step to be included in the analysis. Defaults to last time step in data set.

noNAs

a value between 0 and 1 representing the proportion of allowable NAs for any given time series. NA values are imputed with the mean across the time series for the ordination. Time series exceeding the proportion of NAs specified are removed from the analysis.

splits

number of color breaks for the plot. Options are 4 (quartiles with red and green) or 5 (quintiles with red, yellow, green).

cexlabs

a value indicating scaling for the size of the labels.

indatformat

a format in which the time steps are input, as defined in strptime. Defaults to year with century ("%Y").

outdatformat

a format as defined in strptime which represents the desired format for labeling the plot. Defaults to year with century ("%Y").

graycol

a boolean indicating whether or not grayscale colors should be used. Defaults to FALSE.

method

the ordination method for sorting the time series data. Defaults to principal components analysis ("pca") using prcomp. Other option is non-metric multidimensional scaling ("nmds") using metaMDS.

PC

an integer indicating which ordination axis the time series data should be sorted by on the plot. Specify either 1 (for first axis) or 2 (for second axis).

Note

Data must be input in a data frame where rows represent time steps and columns represent data series.

  • The first columns contains a string of time units in any specified format.

  • Columns 2+ contain data values for the respective time steps.

References

https://www.aoml.noaa.gov/ocd/ocdweb/ESR_GOMIEA/report/GoM_EcosystemStatusReport2017.pdf

Examples

## make traffic plot of Gulf of Mexico fishery landings
 par(mar = c(3, 10, 1, 1))
 trafficLightPlot(GOMlandings)

 trafficLightPlot(GOMlandings, mintime = 1980, maxtime = 2000, splits = 4, method = "nmds")


mandykarnauskas/plotTimeSeries documentation built on Nov. 21, 2024, 12:34 p.m.