display_growth: Display annual growth rates using ggplot2

Description Usage Arguments Value Examples

View source: R/display_growth.R

Description

Display annual growth rates using ggplot2

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
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)))
 display_growth(growth)

EcoFoG/ForestData documentation built on Jan. 20, 2021, 10:04 a.m.