Package 'RDBESvisualise'

Title: Visualisation and Summarisation Tools for RDBES Data
Description: Provides utility functions to summarise and visualise data from Regional Database and Estimation System (RDBES).
Authors: David Currie [aut] (ORCID: <https://orcid.org/0000-0002-3523-6895>), Richard Meitern [aut] (ORCID: <https://orcid.org/0000-0002-2600-3002>), Nuno Prista [aut] (ORCID: <https://orcid.org/0000-0002-5145-7241>), Nicholas Carey [aut], Petri Sarvamaa [aut], Kirsten Birch Håkansson [aut], Karolina Molla Gazi [aut], Julia Wischnewski [aut], Ana Cláudia Fernandes [aut] (ORCID: <https://orcid.org/0000-0001-6041-8140>), Katarzyna Krakówka [aut], Marta Szymańska [aut], Nicolas Goñi [aut], Annica de Groote [ctb], Jonathan Ball [ctb], Jonathan Rault [ctb], Antti Sykkö [ctb], Liz Clarke [ctb], Eros Quesada [ctb], Jonathan Stounberg [ctb], Colin Millar [cre]
Maintainer: Colin Millar <[email protected]>
License: GPL-3
Version: 0.1.1
Built: 2026-11-23 16:14:17 UTC
Source: https://github.com/ices-tools-dev/RDBESvisualise

Help Index


Summarise numeric and categorical variables by grouping variables

Description

amountByGroup() summarises one or more variables (numeric and/or categorical) by one or more grouping variables. Numeric variables are aggregated using sums, while categorical variables are summarised as frequency counts. The function supports flexible filtering, percentage conversion, grouped summaries, and optional plotting. Designed for RDBES datasets or similar.

Usage

amountByGroup(
  data,
  var,
  valBy,
  filters = NULL,
  output_type = c("table", "plot"),
  asPct = FALSE,
  assign_to_global = FALSE,
  verbose = TRUE
)

Arguments

data

A data.frame or data.table.

var

Character vector of column names to summarise.

valBy

Character vector of grouping variables.

filters

Optional named list of filters applied before aggregation.

output_type

One of "table" or "plot".

asPct

Logical; if TRUE, numeric summaries are converted to percentages.

assign_to_global

Logical; if TRUE, assigns result to .GlobalEnv.

verbose

Logical; print progress messages.

Details

Main features:

  • Numeric variables are summed (optionally converted to percentages).

  • Categorical variables are counted as frequencies.

  • Multiple variables can be summarised simultaneously.

  • Optional filtering prior to aggregation.

  • Optional plotting using ggplot2.

When both numeric and categorical variables are supplied, the result is returned as a list with components $numeric and $categorical.

Value

Invisibly returns a data.table or a list of tables.

Examples

## Not run: 

Summarise one numeric variable by year and flag
tbl1 <- amountByGroup(
  data = landings,
  var = "LiveWeight",
  valBy = c("Year", "FlagCountry"),
  filters = list(SpeciesGroup = "COD"),
  asPct = FALSE,
  output_type = "table"
)

Summarise a categorical variable (species name)
tbl2 <- amountByGroup(
  data = landings,
  var = "SpeciesName",
  valBy = "Harbour",
  output_type = "plot"
)

Summarise multiple numeric + categorical variables together
tbl3 <- amountByGroup(
  data = landings,
  var = c("Weight", "NumSamp", "SpeciesName"),
  valBy = c("Year", "FlagCountry"),
  output_type = "table"
)

## End(Not run)