Skip to contents

compare_agri_index() plots and compares time series data for multiple agricultural indices.

Usage

compare_agri_index(
  indexes,
  selection = NULL,
  destination = tempdir(),
  global = TRUE,
  global_name = "global",
  output_title = NULL,
  output_format = c("none", "png", "pdf", "jpg"),
  col = NULL,
  language = "FR",
  add_information = FALSE,
  information = NULL
)

Arguments

indexes

list of dataframes, where each dataframe represents a time series of values.

selection

character, specifying which indexesshould be plotted . If NULL, all indexes are plotted (up to a maximum of 13).

destination

character, path to the directory where results should be saved. Used only if output_format not set to "none". Default to tempdir()

global

boolean, indicating whether there is a "global" index in the plot. Defaults to TRUE.

global_name

character, name of the dataframe in indexes representing the global index. Default to "global".

output_title

character, base name for the output file. If NULL, a default name is generated. Default to NULL

output_format

character, format of the output plot ("none", "png", "pdf", "jpg"). Default to "none" (plot will be shown in R console).

col

character, vector of colors to use for each index. If NULL, default colors are used.

language

character, language for the axis labels and plot title. One of c("FR", "EN"). Defaults to "FR".

add_information

boolean, should series ID information be added to the legend. Default to FALSE.

information

data.frame, containing series ID and crop categories. Required if add_information is TRUE. Default to NULL

Value

This function does not return a value. It generates and optionally saves a plot as a side effect.

Examples

# Preparing some plot data
if (FALSE) { # \dontrun{
series = c(
    ippap_2015 = "010538819",
    ippap_2020 = "010776418",
    cereals_2020 = "010776421",
    vineyard_2020 = "010776443",
    horticulture_2020 = "010776450"
)
download_insee_index(series, verbose = TRUE)
series_list = stats::setNames(
    read_insee_serie(file.path(tempdir(), paste0(series, ".csv"))),
    names(series)
)
# Merging ippap to obtain global series
series_list[["global"]] = merge_insee_index(
    series_list[["ippap_2015"]], series_list[["ippap_2020"]]
)
series_list[c("ippap_2015", "ippap_2020")] = NULL
compare_agri_index(indexes = series_list)
compare_agri_index(indexes = series_list, output_format = "png")

# Adding information
information = data.frame(
   category = names(series_list),
   ippap_2015 = c(rep(NA, 3), series[["ippap_2015"]]),
   ippap_2020 = c(series[-c(1,2)], series[["ippap_2020"]])
)
compare_agri_index(
   indexes = series_list,
   add_information = TRUE,
   information = information
)
} # }