g3_data: Aggregate count data from a data frame to gadget3

View source: R/g3_data.R

g3_dataR Documentation

Aggregate count data from a data frame to gadget3

Description

Aggregates data from a data frame ready to be passed to gadget3. Useful for generating datasets for g3l_catchdistribution, g3l_abundancedistribution and g3_timeareadata. Imitates the behavior of mfdb_sample_* functions and returns the required object attributes as instructed by the params argument.

Usage

g3_data(
  x,
  params = list(),
  method = "count",
  column_names = c(year = "year", step = "month", area = "areacell"),
  floating_point_correction = TRUE,
  verbose = FALSE
)

Arguments

x

A data frame, tibble or data table

params

A list of parameters defining the grouping. See details in mfdb_sample_count.

method

A character defining the aggregation method: use "count" to count occurrences or name of the column that should be summarized in x based on grouping defined by params.

column_names

A named vector explaining the column names which gadget3 expects in x if not the same than in mfdb. See the default suggestion for example.

floating_point_correction

Logical indicating whether 1e-6 should be added to all numeric columns except for year and step. Corrects for floating point issues associated with certain numbers such as 28 and 57.

verbose

Logical indicating whether the function should return messages about potential assumptions when expected data are not specified.

Details

This function attempts to do the same than mfdb_sample_* functions: summarise data ready for gadget3, with the difference that this function uses dataframes instead of a SQL database as input data. Consequently, this function should be independent of mfdb if the functions that generate groups and intervals as the mfdb package (mfdb_interval, mfdb_group) were imported to a project with this function.

Importantly, g3_data() does not attempt to filter other data than length unlike mfdb_sample_* functions that filter all columns passed to params.


gadget-framework/gadgetutils documentation built on Aug. 16, 2024, 8:45 a.m.