plot_lw {ggFishPlots} | R Documentation |
Plot length-weight relationships
Description
Plot length-weight relationships
Usage
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
)
Arguments
dt |
A data.frame, tibble or data.table |
length |
Character argument giving the name of the length column in |
weight |
Character argument giving the name of the age column in |
sex |
Character argument giving the name of the sex column in |
female.sex |
A character denoting female sex in the |
male.sex |
A character denoting male sex in the |
length.unit |
Character argument giving the unit of |
weight.unit |
Character argument giving the unit of |
split.by.sex |
Logical indicating whether the result should be split by sex. |
xlab |
Character giving the x-axis label without unit |
ylab |
Character giving the x-axis label without unit. |
use.nls |
Logical indicating whether the parameters should be calculated using the nonlinear least squares ( |
init.a , init.b |
Numeric values giving the starting value for a and b parameters respecitively for non-linear least-squares estimation (i.e. when |
log.axes |
Logical indicating whether logarithmic axes should be used instead of cartesian ones. |
base_size |
Base size parameter for ggplot. See ggtheme. |
legend.position |
Position of the ggplot legend as a character. See ggtheme. |
correct.units |
Logical indicating whether a and b parameters should be converted for centimeters and grams as in FishBase. |
verbose |
Logical indicating whether to return warnings and messages. |
Details
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.
Value
A ggplot together with the a and b parameters.
Author(s)
Mikko Vihtakari // Institute of Marine Research.
Examples
data(survey_ghl)
# Simple plot
plot_lw(survey_ghl, length = "length", weight = "weight")
# Split by sex
plot_lw(survey_ghl, split.by.sex = TRUE)$plot