weighted.mean,FLQuants,FLQuants-method | R Documentation |
Facilitates the calculation of weighted means across a FLQuants object.
## S4 method for signature 'FLQuants,FLQuants'
weighted.mean(x, w)
x |
Values to be averaged, as an object of class |
w |
weights to be used, as an object of class |
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.
A single FLQuant
object.
The FLR Team
FLCore::FLQuants stats::weighted.mean
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)))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.