Skip to contents

Time series summaries of complex objects are commonly needed, for example for plotting the inputs and outputs of a class like FLStock. These methods allow for simple specification of those metrics by means of function calls and formulas.

Usage

metrics(object, metrics, ...)

# S4 method for class 'FLComp,list'
metrics(object, metrics, ...)

# S4 method for class 'FLS,missing'
metrics(object, metrics, ...)

Arguments

object

A complex FLR object from which to extract time series metrics.

Value

An object, generally of class FLQuants.

See also

Author

The FLR Team

Examples

data(ple4)
# missing
metrics(ple4)
#> $ Rec 
#> An x of class "FLQuant"
#> , , unit = unique, season = all, area = unique
#> 
#>    year
#> age 1957    1958    1959    1960    1961    1962    1963    1964    1965   
#>   1  477074  710748  874712  797702  870799  615691  610017 2449900  664500
#>    year
#> age 1966    1967    1968    1969    1970    1971    1972    1973    1974   
#>   1  579075  428110  418228  666902  671454  433599  367450 1391430 1074920
#>    year
#> age 1975    1976    1977    1978    1979    1980    1981    1982    1983   
#>   1  787372  674010 1033740  879043  915553 1078660  999968 1935350 1375880
#>    year
#> age 1984    1985    1986    1987    1988    1989    1990    1991    1992   
#>   1 1302060 1792220 4303680 1910200 1774940 1250510 1083810  981356  854841
#>    year
#> age 1993    1994    1995    1996    1997    1998    1999    2000    2001   
#>   1  550376  566448  932162  893056 2431310  778427  683151  857525  634808
#>    year
#> age 2002    2003    2004    2005    2006    2007    2008    2009    2010   
#>   1 1792880  557844 1235790  863893  875191 1379750 1135050 1088820 1444570
#>    year
#> age 2011    2012    2013    2014    2015    2016    2017   
#>   1 1608190 1278010 1455050 1640700  895620 1211320 1823000
#> 
#> units:  1000 
#> 
#> $ SSB 
#> An x of class "FLQuant"
#> , , unit = unique, season = all, area = unique
#> 
#>      year
#> age   1957   1958   1959   1960   1961   1962   1963   1964   1965   1966  
#>   all 342223 355375 362119 380052 391386 482245 440658 430475 383583 404516
#>      year
#> age   1967   1968   1969   1970   1971   1972   1973   1974   1975   1976  
#>   all 473938 458977 402865 370472 361610 366129 302365 298094 301757 328726
#>      year
#> age   1977   1978   1979   1980   1981   1982   1983   1984   1985   1986  
#>   all 329116 327544 302271 319090 290780 284211 339238 367251 394666 407972
#>      year
#> age   1987   1988   1989   1990   1991   1992   1993   1994   1995   1996  
#>   all 470952 424696 448230 396458 356947 311431 279962 233481 222203 203391
#>      year
#> age   1997   1998   1999   2000   2001   2002   2003   2004   2005   2006  
#>   all 204948 237863 219149 230902 234211 221902 248312 233478 253737 284447
#>      year
#> age   2007   2008   2009   2010   2011   2012   2013   2014   2015   2016  
#>   all 293330 371837 453026 554245 575459 617539 709948 823276 774157 836453
#>      year
#> age   2017  
#>   all 913290
#> 
#> units:  t 
#> 
#> $ Catch 
#> An x of class "FLQuant"
#> , , unit = unique, season = all, area = unique
#> 
#>      year
#> age   1957   1958   1959   1960   1961   1962   1963   1964   1965   1966  
#>   all  78360  88785 105186 117975 119541 126290 140815 147540 151408 162266
#>      year
#> age   1967   1968   1969   1970   1971   1972   1973   1974   1975   1976  
#>   all 154474 149820 146178 136619 141226 149390 151515 157994 165392 175881
#>      year
#> age   1977   1978   1979   1980   1981   1982   1983   1984   1985   1986  
#>   all 165843 178166 172652 184690 184494 192439 212632 228265 247071 279228
#>      year
#> age   1987   1988   1989   1990   1991   1992   1993   1994   1995   1996  
#>   all 308480 315245 292035 250604 218184 192691 179573 151248 132629 131719
#>      year
#> age   1997   1998   1999   2000   2001   2002   2003   2004   2005   2006  
#>   all 152195 171240 170662 145998 128107 143807 154029 140056 114551 111864
#>      year
#> age   2007   2008   2009   2010   2011   2012   2013   2014   2015   2016  
#>   all 104770 113397 115703 118824 119718 131872 141055 139750 137338 131216
#>      year
#> age   2017  
#>   all 124922
#> 
#> units:  t 
#> 
#> $ F 
#> An x of class "FLQuant"
#> , , unit = unique, season = all, area = unique
#> 
#>      year
#> age   1957  1958  1959  1960  1961  1962  1963  1964  1965  1966  1967  1968 
#>   all 0.242 0.279 0.311 0.324 0.325 0.336 0.367 0.394 0.388 0.362 0.348 0.354
#>      year
#> age   1969  1970  1971  1972  1973  1974  1975  1976  1977  1978  1979  1980 
#>   all 0.364 0.363 0.367 0.399 0.452 0.480 0.461 0.437 0.449 0.488 0.526 0.542
#>      year
#> age   1981  1982  1983  1984  1985  1986  1987  1988  1989  1990  1991  1992 
#>   all 0.541 0.526 0.515 0.523 0.551 0.586 0.616 0.630 0.622 0.606 0.600 0.607
#>      year
#> age   1993  1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004 
#>   all 0.610 0.598 0.598 0.642 0.712 0.724 0.650 0.582 0.572 0.594 0.571 0.477
#>      year
#> age   2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016 
#>   all 0.387 0.333 0.296 0.255 0.216 0.196 0.198 0.207 0.210 0.205 0.201 0.199
#>      year
#> age   2017 
#>   all 0.199
#> 
#> units:  f 
#> 
# metrics = function
metrics(ple4, metrics=function(x) FLQuants(SSB=ssb(x), REC=rec(x),
  F=fbar(x), SSBREC=ssb(x) / rec(x)))
#> $ SSB 
#> An x of class "FLQuant"
#> , , unit = unique, season = all, area = unique
#> 
#>      year
#> age   1957   1958   1959   1960   1961   1962   1963   1964   1965   1966  
#>   all 342223 355375 362119 380052 391386 482245 440658 430475 383583 404516
#>      year
#> age   1967   1968   1969   1970   1971   1972   1973   1974   1975   1976  
#>   all 473938 458977 402865 370472 361610 366129 302365 298094 301757 328726
#>      year
#> age   1977   1978   1979   1980   1981   1982   1983   1984   1985   1986  
#>   all 329116 327544 302271 319090 290780 284211 339238 367251 394666 407972
#>      year
#> age   1987   1988   1989   1990   1991   1992   1993   1994   1995   1996  
#>   all 470952 424696 448230 396458 356947 311431 279962 233481 222203 203391
#>      year
#> age   1997   1998   1999   2000   2001   2002   2003   2004   2005   2006  
#>   all 204948 237863 219149 230902 234211 221902 248312 233478 253737 284447
#>      year
#> age   2007   2008   2009   2010   2011   2012   2013   2014   2015   2016  
#>   all 293330 371837 453026 554245 575459 617539 709948 823276 774157 836453
#>      year
#> age   2017  
#>   all 913290
#> 
#> units:  t 
#> 
#> $ REC 
#> An x of class "FLQuant"
#> , , unit = unique, season = all, area = unique
#> 
#>    year
#> age 1957    1958    1959    1960    1961    1962    1963    1964    1965   
#>   1  477074  710748  874712  797702  870799  615691  610017 2449900  664500
#>    year
#> age 1966    1967    1968    1969    1970    1971    1972    1973    1974   
#>   1  579075  428110  418228  666902  671454  433599  367450 1391430 1074920
#>    year
#> age 1975    1976    1977    1978    1979    1980    1981    1982    1983   
#>   1  787372  674010 1033740  879043  915553 1078660  999968 1935350 1375880
#>    year
#> age 1984    1985    1986    1987    1988    1989    1990    1991    1992   
#>   1 1302060 1792220 4303680 1910200 1774940 1250510 1083810  981356  854841
#>    year
#> age 1993    1994    1995    1996    1997    1998    1999    2000    2001   
#>   1  550376  566448  932162  893056 2431310  778427  683151  857525  634808
#>    year
#> age 2002    2003    2004    2005    2006    2007    2008    2009    2010   
#>   1 1792880  557844 1235790  863893  875191 1379750 1135050 1088820 1444570
#>    year
#> age 2011    2012    2013    2014    2015    2016    2017   
#>   1 1608190 1278010 1455050 1640700  895620 1211320 1823000
#> 
#> units:  1000 
#> 
#> $ F 
#> An x of class "FLQuant"
#> , , unit = unique, season = all, area = unique
#> 
#>      year
#> age   1957  1958  1959  1960  1961  1962  1963  1964  1965  1966  1967  1968 
#>   all 0.242 0.279 0.311 0.324 0.325 0.336 0.367 0.394 0.388 0.362 0.348 0.354
#>      year
#> age   1969  1970  1971  1972  1973  1974  1975  1976  1977  1978  1979  1980 
#>   all 0.364 0.363 0.367 0.399 0.452 0.480 0.461 0.437 0.449 0.488 0.526 0.542
#>      year
#> age   1981  1982  1983  1984  1985  1986  1987  1988  1989  1990  1991  1992 
#>   all 0.541 0.526 0.515 0.523 0.551 0.586 0.616 0.630 0.622 0.606 0.600 0.607
#>      year
#> age   1993  1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004 
#>   all 0.610 0.598 0.598 0.642 0.712 0.724 0.650 0.582 0.572 0.594 0.571 0.477
#>      year
#> age   2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016 
#>   all 0.387 0.333 0.296 0.255 0.216 0.196 0.198 0.207 0.210 0.205 0.201 0.199
#>      year
#> age   2017 
#>   all 0.199
#> 
#> units:  f 
#> 
#> $ SSBREC 
#> An x of class "FLQuant"
#> , , unit = unique, season = all, area = unique
#> 
#>      year
#> age   1957   1958   1959   1960   1961   1962   1963   1964   1965   1966  
#>   all 0.7173 0.5000 0.4140 0.4764 0.4495 0.7833 0.7224 0.1757 0.5773 0.6986
#>      year
#> age   1967   1968   1969   1970   1971   1972   1973   1974   1975   1976  
#>   all 1.1070 1.0974 0.6041 0.5517 0.8340 0.9964 0.2173 0.2773 0.3832 0.4877
#>      year
#> age   1977   1978   1979   1980   1981   1982   1983   1984   1985   1986  
#>   all 0.3184 0.3726 0.3302 0.2958 0.2908 0.1469 0.2466 0.2821 0.2202 0.0948
#>      year
#> age   1987   1988   1989   1990   1991   1992   1993   1994   1995   1996  
#>   all 0.2465 0.2393 0.3584 0.3658 0.3637 0.3643 0.5087 0.4122 0.2384 0.2277
#>      year
#> age   1997   1998   1999   2000   2001   2002   2003   2004   2005   2006  
#>   all 0.0843 0.3056 0.3208 0.2693 0.3689 0.1238 0.4451 0.1889 0.2937 0.3250
#>      year
#> age   2007   2008   2009   2010   2011   2012   2013   2014   2015   2016  
#>   all 0.2126 0.3276 0.4161 0.3837 0.3578 0.4832 0.4879 0.5018 0.8644 0.6905
#>      year
#> age   2017  
#>   all 0.5010
#> 
#> units:  kg 
#> 
# metrics = formula
metrics(ple4, metrics=~ssb)
#> An x of class "FLQuant"
#> , , unit = unique, season = all, area = unique
#> 
#>      year
#> age   1957   1958   1959   1960   1961   1962   1963   1964   1965   1966  
#>   all 342223 355375 362119 380052 391386 482245 440658 430475 383583 404516
#>      year
#> age   1967   1968   1969   1970   1971   1972   1973   1974   1975   1976  
#>   all 473938 458977 402865 370472 361610 366129 302365 298094 301757 328726
#>      year
#> age   1977   1978   1979   1980   1981   1982   1983   1984   1985   1986  
#>   all 329116 327544 302271 319090 290780 284211 339238 367251 394666 407972
#>      year
#> age   1987   1988   1989   1990   1991   1992   1993   1994   1995   1996  
#>   all 470952 424696 448230 396458 356947 311431 279962 233481 222203 203391
#>      year
#> age   1997   1998   1999   2000   2001   2002   2003   2004   2005   2006  
#>   all 204948 237863 219149 230902 234211 221902 248312 233478 253737 284447
#>      year
#> age   2007   2008   2009   2010   2011   2012   2013   2014   2015   2016  
#>   all 293330 371837 453026 554245 575459 617539 709948 823276 774157 836453
#>      year
#> age   2017  
#>   all 913290
#> 
#> units:  t 
metrics(ple4, metrics=list(SSB=~ssb))
#> $ SSB 
#> An x of class "FLQuant"
#> , , unit = unique, season = all, area = unique
#> 
#>      year
#> age   1957   1958   1959   1960   1961   1962   1963   1964   1965   1966  
#>   all 342223 355375 362119 380052 391386 482245 440658 430475 383583 404516
#>      year
#> age   1967   1968   1969   1970   1971   1972   1973   1974   1975   1976  
#>   all 473938 458977 402865 370472 361610 366129 302365 298094 301757 328726
#>      year
#> age   1977   1978   1979   1980   1981   1982   1983   1984   1985   1986  
#>   all 329116 327544 302271 319090 290780 284211 339238 367251 394666 407972
#>      year
#> age   1987   1988   1989   1990   1991   1992   1993   1994   1995   1996  
#>   all 470952 424696 448230 396458 356947 311431 279962 233481 222203 203391
#>      year
#> age   1997   1998   1999   2000   2001   2002   2003   2004   2005   2006  
#>   all 204948 237863 219149 230902 234211 221902 248312 233478 253737 284447
#>      year
#> age   2007   2008   2009   2010   2011   2012   2013   2014   2015   2016  
#>   all 293330 371837 453026 554245 575459 617539 709948 823276 774157 836453
#>      year
#> age   2017  
#>   all 913290
#> 
#> units:  t 
#> 
metrics(ple4, metrics=list(SBMSY=~ssb/SBMSY), FLPar(SBMSY=3.87e4))
#> $ SBMSY 
#> An x of class "FLQuant"
#> , , unit = unique, season = all, area = unique
#> 
#>      year
#> age   1957  1958  1959  1960  1961  1962  1963  1964  1965  1966  1967  1968 
#>   all  8.84  9.18  9.36  9.82 10.11 12.46 11.39 11.12  9.91 10.45 12.25 11.86
#>      year
#> age   1969  1970  1971  1972  1973  1974  1975  1976  1977  1978  1979  1980 
#>   all 10.41  9.57  9.34  9.46  7.81  7.70  7.80  8.49  8.50  8.46  7.81  8.25
#>      year
#> age   1981  1982  1983  1984  1985  1986  1987  1988  1989  1990  1991  1992 
#>   all  7.51  7.34  8.77  9.49 10.20 10.54 12.17 10.97 11.58 10.24  9.22  8.05
#>      year
#> age   1993  1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004 
#>   all  7.23  6.03  5.74  5.26  5.30  6.15  5.66  5.97  6.05  5.73  6.42  6.03
#>      year
#> age   2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016 
#>   all  6.56  7.35  7.58  9.61 11.71 14.32 14.87 15.96 18.34 21.27 20.00 21.61
#>      year
#> age   2017 
#>   all 23.60
#> 
#> units:  t 
#> 
# metrics = list
metrics(ple4, metrics=list(SSB=ssb, REC=rec, F=fbar))
#> $ SSB 
#> An x of class "FLQuant"
#> , , unit = unique, season = all, area = unique
#> 
#>      year
#> age   1957   1958   1959   1960   1961   1962   1963   1964   1965   1966  
#>   all 342223 355375 362119 380052 391386 482245 440658 430475 383583 404516
#>      year
#> age   1967   1968   1969   1970   1971   1972   1973   1974   1975   1976  
#>   all 473938 458977 402865 370472 361610 366129 302365 298094 301757 328726
#>      year
#> age   1977   1978   1979   1980   1981   1982   1983   1984   1985   1986  
#>   all 329116 327544 302271 319090 290780 284211 339238 367251 394666 407972
#>      year
#> age   1987   1988   1989   1990   1991   1992   1993   1994   1995   1996  
#>   all 470952 424696 448230 396458 356947 311431 279962 233481 222203 203391
#>      year
#> age   1997   1998   1999   2000   2001   2002   2003   2004   2005   2006  
#>   all 204948 237863 219149 230902 234211 221902 248312 233478 253737 284447
#>      year
#> age   2007   2008   2009   2010   2011   2012   2013   2014   2015   2016  
#>   all 293330 371837 453026 554245 575459 617539 709948 823276 774157 836453
#>      year
#> age   2017  
#>   all 913290
#> 
#> units:  t 
#> 
#> $ REC 
#> An x of class "FLQuant"
#> , , unit = unique, season = all, area = unique
#> 
#>    year
#> age 1957    1958    1959    1960    1961    1962    1963    1964    1965   
#>   1  477074  710748  874712  797702  870799  615691  610017 2449900  664500
#>    year
#> age 1966    1967    1968    1969    1970    1971    1972    1973    1974   
#>   1  579075  428110  418228  666902  671454  433599  367450 1391430 1074920
#>    year
#> age 1975    1976    1977    1978    1979    1980    1981    1982    1983   
#>   1  787372  674010 1033740  879043  915553 1078660  999968 1935350 1375880
#>    year
#> age 1984    1985    1986    1987    1988    1989    1990    1991    1992   
#>   1 1302060 1792220 4303680 1910200 1774940 1250510 1083810  981356  854841
#>    year
#> age 1993    1994    1995    1996    1997    1998    1999    2000    2001   
#>   1  550376  566448  932162  893056 2431310  778427  683151  857525  634808
#>    year
#> age 2002    2003    2004    2005    2006    2007    2008    2009    2010   
#>   1 1792880  557844 1235790  863893  875191 1379750 1135050 1088820 1444570
#>    year
#> age 2011    2012    2013    2014    2015    2016    2017   
#>   1 1608190 1278010 1455050 1640700  895620 1211320 1823000
#> 
#> units:  1000 
#> 
#> $ F 
#> An x of class "FLQuant"
#> , , unit = unique, season = all, area = unique
#> 
#>      year
#> age   1957  1958  1959  1960  1961  1962  1963  1964  1965  1966  1967  1968 
#>   all 0.242 0.279 0.311 0.324 0.325 0.336 0.367 0.394 0.388 0.362 0.348 0.354
#>      year
#> age   1969  1970  1971  1972  1973  1974  1975  1976  1977  1978  1979  1980 
#>   all 0.364 0.363 0.367 0.399 0.452 0.480 0.461 0.437 0.449 0.488 0.526 0.542
#>      year
#> age   1981  1982  1983  1984  1985  1986  1987  1988  1989  1990  1991  1992 
#>   all 0.541 0.526 0.515 0.523 0.551 0.586 0.616 0.630 0.622 0.606 0.600 0.607
#>      year
#> age   1993  1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004 
#>   all 0.610 0.598 0.598 0.642 0.712 0.724 0.650 0.582 0.572 0.594 0.571 0.477
#>      year
#> age   2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016 
#>   all 0.387 0.333 0.296 0.255 0.216 0.196 0.198 0.207 0.210 0.205 0.201 0.199
#>      year
#> age   2017 
#>   all 0.199
#> 
#> units:  f 
#> 
metrics(ple4, metrics=list(SSB=~ssb, REC=rec, F=fbar))
#> $ SSB 
#> An x of class "FLQuant"
#> , , unit = unique, season = all, area = unique
#> 
#>      year
#> age   1957   1958   1959   1960   1961   1962   1963   1964   1965   1966  
#>   all 342223 355375 362119 380052 391386 482245 440658 430475 383583 404516
#>      year
#> age   1967   1968   1969   1970   1971   1972   1973   1974   1975   1976  
#>   all 473938 458977 402865 370472 361610 366129 302365 298094 301757 328726
#>      year
#> age   1977   1978   1979   1980   1981   1982   1983   1984   1985   1986  
#>   all 329116 327544 302271 319090 290780 284211 339238 367251 394666 407972
#>      year
#> age   1987   1988   1989   1990   1991   1992   1993   1994   1995   1996  
#>   all 470952 424696 448230 396458 356947 311431 279962 233481 222203 203391
#>      year
#> age   1997   1998   1999   2000   2001   2002   2003   2004   2005   2006  
#>   all 204948 237863 219149 230902 234211 221902 248312 233478 253737 284447
#>      year
#> age   2007   2008   2009   2010   2011   2012   2013   2014   2015   2016  
#>   all 293330 371837 453026 554245 575459 617539 709948 823276 774157 836453
#>      year
#> age   2017  
#>   all 913290
#> 
#> units:  t 
#> 
#> $ REC 
#> An x of class "FLQuant"
#> , , unit = unique, season = all, area = unique
#> 
#>    year
#> age 1957    1958    1959    1960    1961    1962    1963    1964    1965   
#>   1  477074  710748  874712  797702  870799  615691  610017 2449900  664500
#>    year
#> age 1966    1967    1968    1969    1970    1971    1972    1973    1974   
#>   1  579075  428110  418228  666902  671454  433599  367450 1391430 1074920
#>    year
#> age 1975    1976    1977    1978    1979    1980    1981    1982    1983   
#>   1  787372  674010 1033740  879043  915553 1078660  999968 1935350 1375880
#>    year
#> age 1984    1985    1986    1987    1988    1989    1990    1991    1992   
#>   1 1302060 1792220 4303680 1910200 1774940 1250510 1083810  981356  854841
#>    year
#> age 1993    1994    1995    1996    1997    1998    1999    2000    2001   
#>   1  550376  566448  932162  893056 2431310  778427  683151  857525  634808
#>    year
#> age 2002    2003    2004    2005    2006    2007    2008    2009    2010   
#>   1 1792880  557844 1235790  863893  875191 1379750 1135050 1088820 1444570
#>    year
#> age 2011    2012    2013    2014    2015    2016    2017   
#>   1 1608190 1278010 1455050 1640700  895620 1211320 1823000
#> 
#> units:  1000 
#> 
#> $ F 
#> An x of class "FLQuant"
#> , , unit = unique, season = all, area = unique
#> 
#>      year
#> age   1957  1958  1959  1960  1961  1962  1963  1964  1965  1966  1967  1968 
#>   all 0.242 0.279 0.311 0.324 0.325 0.336 0.367 0.394 0.388 0.362 0.348 0.354
#>      year
#> age   1969  1970  1971  1972  1973  1974  1975  1976  1977  1978  1979  1980 
#>   all 0.364 0.363 0.367 0.399 0.452 0.480 0.461 0.437 0.449 0.488 0.526 0.542
#>      year
#> age   1981  1982  1983  1984  1985  1986  1987  1988  1989  1990  1991  1992 
#>   all 0.541 0.526 0.515 0.523 0.551 0.586 0.616 0.630 0.622 0.606 0.600 0.607
#>      year
#> age   1993  1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004 
#>   all 0.610 0.598 0.598 0.642 0.712 0.724 0.650 0.582 0.572 0.594 0.571 0.477
#>      year
#> age   2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016 
#>   all 0.387 0.333 0.296 0.255 0.216 0.196 0.198 0.207 0.210 0.205 0.201 0.199
#>      year
#> age   2017 
#>   all 0.199
#> 
#> units:  f 
#>