backCalc {RFishBC} | R Documentation |
Back-calculate length at previous ages from standard data format.
Description
Back-calculates length at previous ages from a data.frame that was primarily created from combineData
and digitizeRadii
. One of several back-calculation models, described in bcFuns
and Vigliola and Meekan (2009), can be used. Parameter estimates from various models of fish length on structure radius or structure radius on fish length are computed internally and used in the back-calculations. This function is intended to make back-calculation of fish length at previous ages as streamlined as possible.
Usage
backCalc(
dat,
lencap,
BCM,
inFormat,
outFormat = inFormat,
a = NULL,
L0p = NULL,
R0p = NULL,
L0 = NULL,
R0 = NULL,
deletePlusGrowth = TRUE,
digits = getOption("digits")
)
Arguments
dat |
A data.frame created with |
lencap |
The unquoted name of the length-at-capture variable. |
BCM |
A single numeric between 1 and 22 or a string that indicates which model to use (based on numbers and names in Vigliola and Meekan (2009)). See Details in |
inFormat |
The format of the data in |
outFormat |
The format for the returned data.frame. Choices are as described for |
a |
The fish length when the structure first forms as used in the Fraser-Lee model (i.e., |
L0p |
The length at the “Biological Intercept” point. Only used in the “Biological Intercept” ( |
R0p |
The structure radius at the “Biological Intercept” point. Only used in the “Biological Intercept” ( |
L0 |
The length at the arbitrarily selected point in the “Fry” ( |
R0 |
The structure radius at the arbitrarily selected point in the “Fry” ( |
deletePlusGrowth |
A logical that indicates whether the radial measurement that corresponds to “plus-growth” on the structure should be deleted ( |
digits |
Number of digits to which the back-calculated lengths should be rounded. Defaults to the value returned by |
Value
A data.frame similar to dat
but with the radial measurements replaced by back-calculated lengths at previous ages.
Author(s)
Derek H. Ogle, DerekOgle51@gmail.com
Examples
## Get some data
data(SMBassWB1,package="RFishBC") ## fish data
data(SMBassWB2,package="RFishBC") ## rad data
# Simplify to 3 fish so we can see what is going on
tmp1 <- subset(SMBassWB1,id %in% c(377,378,379))
tmp2 <- subset(SMBassWB2,id %in% c(377,378,379))
# Combine data frames to form a wide data frame (i.e., a left join)
wdat1 <- merge(tmp1,tmp2,by="id",all.x=TRUE)
wdat1
# Make a long data frame for examples (remove annuli with NA rads)
ldat1 <- tidyr::pivot_longer(wdat1,rad1:rad9,names_to="ann",names_prefix="rad",
values_to="rad")
ldat1 <- subset(ldat1,!is.na(rad))
ldat1 <- as.data.frame(ldat1)
ldat1
## Back-calculate using Dahl-Lea method
# wide in and wide out
wwres1 <- backCalc(wdat1,lencap,BCM="DALE",inFormat="wide",digits=0)
wwres1
# wide in and long out
wlres1 <- backCalc(wdat1,lencap,BCM="DALE",inFormat="wide",
outFormat="long",digits=0)
wlres1
# long in and wide out
lwres1 <- backCalc(ldat1,lencap,BCM="DALE",inFormat="long",digits=0)
lwres1
# wide in and long out
llres1 <- backCalc(ldat1,lencap,BCM="DALE",inFormat="long",
outFormat="long",digits=0)
llres1
## Situation with no radial measurements for some fish
# Create an extra fish with length (tmp1) but no rad
tmp1a <- rbind(tmp1,
data.frame(id=999,
species="SMB",lake="WB",gear="E",
yearcap=1990,lencap=225))
wdat2 <- merge(tmp1a,tmp2,by="id",all.x=TRUE)
wdat2
# wide in and wide out
wwres2 <- backCalc(wdat2,lencap,BCM="DALE",inFormat="wide",digits=0)
wwres2