Plot length-weight relationships
plot_lw(
dt,
length = "length",
weight = "weight",
sex = "sex",
female.sex = "F",
male.sex = "M",
length.unit = "cm",
weight.unit = "kg",
split.by.sex = FALSE,
xlab = "Total length",
ylab = "Weight",
use.nls = FALSE,
init.a = NULL,
init.b = NULL,
log.axes = FALSE,
base_size = 8,
legend.position = "bottom",
correct.units = FALSE,
verbose = TRUE
)
A ggplot together with the a and b parameters.
A data.frame, tibble or data.table
Character argument giving the name of the length column in dt
Character argument giving the name of the age column in dt
Character argument giving the name of the sex column in dt
. Ignored if split.by.sex == FALSE
.
A character denoting female sex in the sex
column of dt
A character denoting male sex in the sex
column of dt
Character argument giving the unit of length
. Will be used in the labels of the figure and for conversion of the a parameter. Allowed values for the conversion: "mm" (millimmeters), "cm" (centimeters), and "m" (meters).
Character argument giving the unit of weight
. Will be used in the labels of the figure and for conversion of the a parameter. Allowed values: "g" (grams), "kg" (kilograms), and "t" (metric tons).
Logical indicating whether the result should be split by sex.
Character giving the x-axis label without unit
Character giving the x-axis label without unit.
Logical indicating whether the parameters should be calculated using the nonlinear least squares (nls; TRUE
) method over the log-log transformed linear model (lm; FALSE
) method.
Numeric values giving the starting value for a and b parameters respecitively for non-linear least-squares estimation (i.e. when use.nls = TRUE
). If NULL
, default values are guessed.
Logical indicating whether logarithmic axes should be used instead of cartesian ones.
Base size parameter for ggplot. See ggtheme.
Position of the ggplot legend as a character. See ggtheme.
Logical indicating whether a and b parameters should be converted for centimeters and grams as in FishBase.
Logical indicating whether to return warnings and messages.
Mikko Vihtakari // Institute of Marine Research.
It is crucial to get the units right when calculating length-weight relationships. In models, the length and weight units should often match those of the data going into the model, while in comparisons with FishBase, the units of length and weight should be centimetres and grams, respectively. If the units are wrong, the intercept, a, will be off the FishBase scale by orders of magnitude (see FishBase). If correct.units = TRUE
, plot_lw()
attempts to correct for the units to the FishBase standard (cm and g). The function also returns a warning when the returned parameters are not within expected bounds for cm and g estimation. You can ignore this warning if you want to estimate values. Comparing your a and b with those in FishBase for the species is a good idea. This function may contain bugs.
data(survey_ghl)
# Simple plot
plot_lw(survey_ghl, length = "length", weight = "weight")
# \donttest{
# Split by sex
plot_lw(survey_ghl, split.by.sex = TRUE)$plot
# }
Run the code above in your browser using DataLab