weighted.mean-FLQuants-FLQuants-method: Weighted means along a FLQuants.

weighted.mean,FLQuants,FLQuants-methodR Documentation

Weighted means along a FLQuants.

Description

Facilitates the calculation of weighted means across a FLQuants object.

Usage

## S4 method for signature 'FLQuants,FLQuants'
weighted.mean(x, w)

Arguments

x

Values to be averaged, as an object of class FLQuants.

w

weights to be used, as an object of class FLQuants.

Details

An object of class FLQuants containing elements over which an average is to computed, is combined with another one, of the same length, containing values to be used as weights. The overall weighted mean is calculated by computing the product of each element to its corresponding weight, and dividing by the sum of all weights. NAs in the value elements are substituted for zeroes, so do not influence the mean.

Value

A single FLQuant object.

Author(s)

The FLR Team

See Also

FLCore::FLQuants stats::weighted.mean

Examples

data(ple4)
# Weighted mean of landings and discards weights-at-age
weighted.mean(FLQuants(L=landings.wt(ple4), D=discards.wt(ple4)),
  FLQuants(L=landings.n(ple4), D=discards.n(ple4)))

flr/FLCore documentation built on May 4, 2024, midnight