View source: R/plot_trend_stack.r
plot_trend_stack | R Documentation |
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
plot_trend_stack(species_change)
species_change |
factor vector of change categories. This should have the following levels "strong increase", "increase", "no change", "decrease", "strong decrease". |
Returns a data.frame of the data in the plot. A plot is sent to the device.
### 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'])
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.