plot_trend_stack: Plot species trend stack plots

View source: R/plot_trend_stack.r

plot_trend_stackR Documentation

Plot species trend stack plots

Description

This function is used for reporting on species trends generated in indicators. It takes a vector of categories and plots then in a stacked column plot

Usage

plot_trend_stack(species_change)

Arguments

species_change

factor vector of change categories. This should have the following levels "strong increase", "increase", "no change", "decrease", "strong decrease".

Value

Returns a data.frame of the data in the plot. A plot is sent to the device.

Examples

### Running from an array ####
set.seed(123)

# number of species
nsp = 50

# number of years
nyr = 40

#number of iterations
iter = 500

# Build a random set of data
myArray <- array(data = rnorm(n = nsp*nyr*iter,
                              mean = 0.5,
                              sd = 0.1),
                 dim = c(nsp, nyr, iter),
                 dimnames = list(paste0('SP',1:nsp),
                                 1:nyr,
                                 1:iter))

# Ensure values are bounded by 0 and 1
myArray[myArray > 1] <- 1
myArray[myArray < 0] <- 0

# Run the lambda_indicator method on this data                
myIndicator <- lambda_indicator(myArray)

# Plot the trend stack
plot_trend_stack(myIndicator$species_change[,'category'])

BiologicalRecordsCentre/BRCindicators documentation built on April 22, 2024, 2:32 p.m.