Skip to contents

Facilitates the calculation of weighted means across a FLQuants object.

Usage

# S4 method for 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.

Value

A single FLQuant object.

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.

See also

FLCore::FLQuants stats::weighted.mean

Author

The FLR Team

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)))
#> An object of class "FLQuant"
#> , , unit = unique, season = all, area = unique
#> 
#>     year
#> age  1957     1958     1959     1960     1961     1962     1963     1964    
#>   1  0.043999 0.047000 0.051000 0.045000 0.044000 0.042000 0.048000 0.032000
#>   2  0.109801 0.105531 0.119977 0.115036 0.101425 0.099279 0.109657 0.125989
#>   3  0.194296 0.189472 0.191506 0.203724 0.180139 0.181375 0.174760 0.203920
#>   4  0.256615 0.256336 0.260406 0.287076 0.301163 0.273064 0.304230 0.271018
#>   5  0.349100 0.329376 0.345271 0.377377 0.402368 0.396960 0.391876 0.378894
#>   6  0.455454 0.452345 0.471905 0.479940 0.506119 0.538035 0.531254 0.484717
#>   7  0.532988 0.512971 0.591979 0.600988 0.603987 0.569980 0.623985 0.627988
#>   8  0.588982 0.614964 0.622952 0.682962 0.670966 0.691974 0.666969 0.699965
#>   9  0.395964 0.664949 0.749944 0.723929 0.811933 0.776924 0.714950 0.736908
#>   10 0.997959 0.991965 0.999970 1.093964 1.070964 1.126954 1.027970 1.004970
#>     year
#> age  1965     1966     1967     1968     1969     1970     1971     1972    
#>   1  0.038000 0.038000 0.035999 0.060000 0.052007 0.049160 0.057058 0.066877
#>   2  0.075866 0.104304 0.110549 0.116347 0.174246 0.131116 0.159854 0.207158
#>   3  0.214406 0.148098 0.189574 0.223414 0.271611 0.268303 0.276554 0.289992
#>   4  0.313280 0.314817 0.234828 0.274537 0.283588 0.352160 0.388422 0.407373
#>   5  0.381437 0.427637 0.422016 0.339914 0.356021 0.393751 0.444319 0.486404
#>   6  0.468814 0.482866 0.543256 0.516098 0.408318 0.440916 0.512235 0.539756
#>   7  0.538992 0.558990 0.596989 0.589983 0.572974 0.498998 0.541984 0.607979
#>   8  0.662961 0.623983 0.661974 0.595971 0.654967 0.671964 0.606994 0.645971
#>   9  0.725914 0.689948 0.737946 0.685915 0.657962 0.743909 0.698947 0.673982
#>   10 0.886975 0.932969 0.977957 0.910967 0.892974 0.891969 0.890974 0.938971
#>     year
#> age  1973     1974     1975     1976     1977     1978     1979     1980    
#>   1  0.045283 0.056495 0.068767 0.087787 0.071297 0.069846 0.066755 0.055802
#>   2  0.205176 0.120785 0.151806 0.180926 0.217858 0.190274 0.190466 0.196997
#>   3  0.333995 0.343206 0.204961 0.261605 0.245025 0.315341 0.295421 0.342960
#>   4  0.403174 0.403747 0.392940 0.347254 0.318061 0.364251 0.337713 0.399370
#>   5  0.478238 0.472376 0.492452 0.509426 0.395996 0.432299 0.426454 0.471181
#>   6  0.537635 0.552275 0.585128 0.591583 0.551315 0.486444 0.472122 0.542439
#>   7  0.604968 0.608978 0.635984 0.640979 0.646945 0.608967 0.549993 0.587979
#>   8  0.626970 0.692947 0.702944 0.704946 0.720928 0.686894 0.674948 0.661962
#>   9  0.676947 0.706939 0.782910 0.740877 0.714912 0.775834 0.795858 0.771797
#>   10 0.841983 0.925980 1.018976 0.979962 0.977947 0.949934 0.959948 1.012908
#>     year
#> age  1981     1982     1983     1984     1985     1986     1987     1988    
#>   1  0.048365 0.055830 0.051689 0.053062 0.054057 0.049257 0.043000 0.043000
#>   2  0.183437 0.152001 0.152694 0.149910 0.169134 0.141397 0.113402 0.101804
#>   3  0.326828 0.308248 0.274762 0.265457 0.267967 0.275409 0.218606 0.197485
#>   4  0.414729 0.420607 0.379126 0.321042 0.333496 0.310525 0.343365 0.275873
#>   5  0.501685 0.511917 0.506954 0.470452 0.443875 0.402396 0.375422 0.415128
#>   6  0.555582 0.605900 0.601997 0.588348 0.561543 0.471807 0.470664 0.476689
#>   7  0.603969 0.663973 0.676959 0.676968 0.666955 0.667978 0.573979 0.589985
#>   8  0.641961 0.711936 0.770909 0.725935 0.729903 0.749920 0.727922 0.679945
#>   9  0.724928 0.737919 0.814865 0.838846 0.806857 0.855849 0.834822 0.807882
#>   10 1.006917 0.983944 0.983941 1.035921 1.020912 1.013928 0.992912 1.016921
#>     year
#> age  1989     1990     1991     1992     1993     1994     1995     1996    
#>   1  0.047111 0.053316 0.056328 0.054789 0.062608 0.063660 0.071146 0.053846
#>   2  0.117643 0.129659 0.149493 0.145431 0.160205 0.179072 0.182859 0.140176
#>   3  0.215080 0.210649 0.210932 0.225705 0.249957 0.256510 0.282589 0.267965
#>   4  0.291297 0.290494 0.272753 0.275225 0.303272 0.331360 0.333654 0.336259
#>   5  0.364309 0.359634 0.349364 0.324154 0.339674 0.372247 0.372883 0.412679
#>   6  0.512269 0.439763 0.449276 0.410348 0.406913 0.416102 0.419083 0.463592
#>   7  0.590975 0.585968 0.525990 0.529995 0.511991 0.490993 0.473992 0.489980
#>   8  0.667958 0.689926 0.665960 0.606975 0.629973 0.609971 0.592967 0.552953
#>   9  0.784831 0.760900 0.742884 0.718891 0.719903 0.730933 0.733853 0.711873
#>   10 0.939919 1.009880 0.923918 0.890936 0.855927 0.905917 0.905884 0.857914
#>     year
#> age  1997     1998     1999     2000     2001     2002     2003     2004    
#>   1  0.045137 0.047196 0.053825 0.063148 0.090053 0.056714 0.065718 0.054372
#>   2  0.128986 0.093865 0.103245 0.123154 0.135808 0.130844 0.123961 0.124949
#>   3  0.220379 0.208050 0.198554 0.209624 0.196628 0.221728 0.226407 0.220420
#>   4  0.353209 0.298684 0.266515 0.274163 0.233921 0.285107 0.283692 0.296929
#>   5  0.408398 0.449011 0.413306 0.371930 0.303216 0.326126 0.335699 0.375498
#>   6  0.472671 0.544009 0.414278 0.452321 0.409800 0.426357 0.385257 0.421241
#>   7  0.540972 0.612968 0.537933 0.564982 0.576465 0.469180 0.419098 0.505507
#>   8  0.573943 0.672883 0.636879 0.600437 0.700436 0.643572 0.634464 0.559824
#>   9  0.615899 0.686827 0.747766 0.751606 0.795388 0.759522 0.762447 0.796136
#>   10 0.911896 0.898866 0.803876 0.887791 0.798831 0.903724 0.856513 0.871236
#>     year
#> age  2005     2006     2007     2008     2009     2010     2011     2012    
#>   1  0.067422 0.060317 0.058775 0.056569 0.061207 0.061822 0.047647 0.052327
#>   2  0.117393 0.139368 0.113666 0.123499 0.124699 0.131690 0.114740 0.096187
#>   3  0.212930 0.211812 0.222959 0.247632 0.232112 0.226039 0.211950 0.195563
#>   4  0.297902 0.293315 0.310085 0.324622 0.326594 0.311303 0.277422 0.294436
#>   5  0.351575 0.374795 0.351229 0.389383 0.399101 0.395925 0.369451 0.348424
#>   6  0.347476 0.383401 0.375268 0.436803 0.465827 0.442379 0.453226 0.425402
#>   7  0.453163 0.428475 0.490651 0.368272 0.518436 0.462564 0.595436 0.509182
#>   8  0.554110 0.456878 0.357361 0.468685 0.440965 0.573445 0.444870 0.557246
#>   9  0.616866 0.530799 0.586515 0.639565 0.667432 0.681865 0.555780 0.557920
#>   10 0.909298 0.747735 0.631758 0.637659 0.791518 0.648744 0.803854 0.679823
#>     year
#> age  2013     2014     2015     2016     2017    
#>   1  0.050915 0.025005 0.026000 0.048000 0.051034
#>   2  0.091130 0.093435 0.080271 0.083793 0.085895
#>   3  0.178565 0.171657 0.161845 0.157402 0.158552
#>   4  0.273559 0.253256 0.257901 0.243039 0.218409
#>   5  0.344682 0.317605 0.325621 0.298878 0.314393
#>   6  0.409448 0.396089 0.393707 0.352469 0.386271
#>   7  0.490250 0.472624 0.461250 0.422309 0.437717
#>   8  0.599009 0.541619 0.480815 0.465186 0.531501
#>   9  0.606877 0.627925 0.581978 0.555971 0.641979
#>   10 0.679910 0.649906 0.599938 0.683933 0.734886
#> 
#> units:  NA