Display annual growth rates using ggplot2

display_growth(
  growth,
  type = "ribbon",
  time_col = "time",
  color_col = "Plot",
  growth_variable = "mean",
  faceting = FALSE,
  title = "Annual growth in function of census intervals.",
  subtitle = NULL,
  save_graph = FALSE,
  device = "png",
  path_save = file.path("ForestGraphs", paste0("annual_mortality_recruitment_", type,
    ".png")),
  name = "annual_growth.png",
  create_folder = FALSE,
  overwrite = FALSE,
  ordered_percentiles = c("P5", "P95"),
  ...
)

Arguments

growth

A data.frame outputed from compute_growth

type

Character, the type of graph (recommended: "line" or "ribbon")

time_col

Character, name of the column corresponding to census time

color_col

Character, name of the colomn used to define lines' colors, defaults to "Plot".

growth_variable

Character

faceting

Character, name of the variable used for faceting -see after- but defaults to FALSE i.e. no faceting. NB: faceting refers to using a grouping variable to layout multiple plots, each corresponding to a category of the grouping variable. See details for a pratical explanation. The scales are free on the x axis: t correspond to several groups not necessarily having the same censusing temporal resolution; but are bound on the y-axis: the values are displayed on the same scale for comparison purposes.

title

Character,title of the graph.

subtitle

Character, subtitle of the graph. Defaults to NULL

save_graph

Logical, indicates whether the graph must be saved or not. Defaults to FALSE. If TRUE, please set the above described arguments in an appropriate way.

device

Relevant if save_graph=TRUE. Character, the graphical device to be used to save the graph.

path_save

Relevant if save_graph=TRUE. Character, a path indicating in which FOLDER the graph has to be saved.

name

Relevant if save_graph=TRUE. Character, the name of the folder containing the graph. It can be followd by the extension corresponding to the device - avoid .jpg for the jpeg device, use .jpeg instead. If the extension is missing, it is automatically added according to the selected device.

create_folder

Relevant if save_graph=TRUE. Logical, indicated whether the folders in the given path must be created in case they do not exist yet, or not.

overwrite

Relevant if save_graph=TRUE. Logical, indicating whether a file already existing under the same name must be overwritten, or kept. In the second case, the function aborts with an explicit error message.

ordered_percentiles

Numeric, if plotting a ribbon, please indicate the percentiles used when aggregating the data.

...

Additional arguments. Notably, verbose = F turns most warnings off

Value

A ggplot graph

Examples

data(example_size_corr) growth <- suppressWarnings(compute_growth(example_size_corr, size_col = "size_corr", measure_type = "cir", status_col = "CodeAlive", id_col= "idTree", time_col = "CensusYear", what_output = "annual", aggregate = TRUE, by = c("Plot"), stat = "mean", percentiles = c(5,95)))
#> The growth rates were not computed when tree life status was 0 (dead) or NA (unseen or uncertain), thus the growth rate on these lines was set to NA
display_growth(growth)
#> $mapping #> Aesthetic mapping: #> * `ymin` -> `P95` #> * `ymax` -> `P5` #> * `fill` -> `Plot` #> * `x` -> `time` #> #> $alpha #> [1] 0.4 #>