Aggregate the catch data contained in a catch dataset and update the biomass dataset with the subtracted catch.

spm_aggregate_catch(
  biomass,
  catch,
  biomass_variable,
  catch_variable,
  corrections = NULL,
  fun = sum,
  group_by = "spacetime",
  fill,
  apply_to_df = FALSE,
  ...
)

# S4 method for sspm_dataset,sspm_dataset,character,character
spm_aggregate_catch(
  biomass,
  catch,
  biomass_variable,
  catch_variable,
  corrections = NULL,
  fun = sum,
  group_by = "spacetime",
  fill,
  apply_to_df = FALSE,
  ...
)

Arguments

biomass

[sspm_dataset (smoothed)] The dataset containing the biomass variable.

catch

[sspm_dataset] The dataset containing the catch variable.

biomass_variable

[character] The biomass variab of biomass.

catch_variable

[character] The catch column of catch.

corrections

[data.frame] Optional landings corrections.

fun

[function] Function to use to aggregate data.

group_by

[character] One of time, space and spacetime.

fill

[logical OR numeric OR function] Whether to complete the incomplete cases, default to FALSE for no completion.

apply_to_df

[logical] Wether fun applied to the data frame group or to variable, default to FALSE.

...

More arguments passed onto fun

Value

Updated sspm_dataset.

Examples

if (FALSE) {
spm_aggregate_catch(biomass = biomass_smooth, catch = catch_dataset,
                    biomass_variable = "weight_per_km2",
                    catch_variable = "catch",
                    fill = mean)
}