aggregator: aggregator

View source: R/aggregator.R

aggregatorR Documentation

aggregator

Description

This function takes a dataframe with coordinates, and facilitates aggregating the data for specific (user-specified) fields. It outputs a gridded version of the original data. Any numeric field can be aggregated, and aggregate values can be one or more of SUMs, MEANs and/or COUNTs

Usage

aggregator(
  df = NULL,
  lat.field = "LATITUDE",
  lon.field = "LONGITUDE",
  agg.fields = NULL,
  agg.minutes = 5,
  facet.field = NULL,
  calculate = c("COUNT", "SUM", "MEAN")
)

Arguments

df

a dataframe to be analyzed.

lat.field

the default is "LATITUDE". This is the name of the field holding latitude values (in decimal degrees)

lon.field

the default is "LONGITUDE". This is the name of the field holding longitude values (in decimal degrees)

agg.fields

the default is NULL. This is a vector of 1 or more fields in the data that contain the values you want to aggregate (e.g. calculate the mean, sum or count of). These fields needs to be numeric. The output aggregated data will ONLY have the lat.field, the lon.field and these agg.fields.

agg.minutes

the default is 5. This specifies how many minutes the data should be aggregated by.

facet.field

default is NULL. In cases like bycatch data, you may have a dataframe where each row might represent different species. You probably want a breakdown of each individual species, rather than summing them all up to get some generic weight of all species combined. This is the field that will be used to aggregate data by common values (like Species_Code) .

calculate

the default is c("MEAN", "COUNT", "SUM"). These are the analytics which should be performed for every field identified in agg.field. For example, if KEPT_WT and DISCAD_WT are both identified in agg.field, then for every resultant aggregated polygon (e.g. hexagon), the mean, count and sum of both of these fields is calculated for every polygon.

Value

a data frame

Author(s)

Mike McMahon, Mike.McMahon@dfo-mpo.gc.ca

See Also

Other general_use: DDMMSS_to_DD(), DDMMx_to_DD(), clip_by_poly(), combine_lists(), df_qc_spatial(), df_sf_to_gpkg(), df_to_sf(), drop_cols(), prepare_shape_fields(), subset_by_time(), updateCheck()


Maritimes/Mar.utils documentation built on Feb. 12, 2024, 11:38 p.m.