knitr::opts_chunk$set(
  collapse = TRUE,
  fig.width = 6,
  fig.height = 4,
  comment = "#>"
)
library(trout.modlR)

trout.Modlr currently has two functions to handle biomass data . The get_biomass_data() can be used to parse data from one to three .rdat files at a time. The make_bms_plot() function can be used to plot biomass data. Below are descriptions of how to use these functions.

Get Biomass Data

Biomass data can be parsed from an .rdat file or files using the get_biomass_data() function.

trout_bms1 <- get_biomass_data(dat1 = trout1)
head(trout_bms1)

The get_biomass_data() function can parse up to three .rdat files at a time. By default, biomass data from the will be appended into a single tibble.

trout_bms2 <-get_biomass_data(dat1 = trout1, dat2 = trout2, dat3 = trout3)

DT::datatable(trout_bms2)

Summing Biomass

The argument cumulative can be used to take the sum of biomass values from the models. The grouping arguement specifies how to group the models when calculating the sum. By default, get_biomass_data() "data_type" and "mu". Other options include "species", "model", and "year". Since female stocking biomass is a subset of total biomass, it never makes sense to sum these. As such, "data_type" is a required grouping parameter and cannot be turned off.

Default Grouping

#default cumualtive with grouping = data_type and year
trout_bms3<-get_biomass_data(dat1 = trout1, dat2 = trout2,
                              cumulative = TRUE)


DT::datatable(trout_bms3)

Custom Grouping

#default cumulative with grouping = data_type and year
trout_bms4<-get_biomass_data(dat1 = trout1, dat2 = trout2,
                              cumulative = TRUE,grouping = c("year","model"))


DT::datatable(trout_bms4)

Units

By default, get_biomass_data() outputs biomass in pounds. The pounds arguement can be set to false to output biomass in kg's.

trout_kg <- get_biomass_data(dat1 = trout1, pounds = FALSE)

Plot Biomass Data

The make_bms_plot() can be used to plot biomass data for one to three models. make_bms_plot() takes an .rdat file as input and uses the get_biomass_data() function to parse about the data.

Single Plot

When a single .rdat file is passed to the function a plot of the biomass is for that model is produced. Data are grouped by "data_type".

plot_biomass_data(dat1 = trout1)

Two or more models

Two or models can be passed to plot_biomass_data() to compare biomass data. Two model types can be produced. These are "cumulative" and "multiple".

Compare Models

When two to three models are passed to plot_biomass_data() and type is set to "multiple" biomass data are compared between models.

plot_biomass_data(dat1 = trout1, dat2 = trout2, type = "multiple")

Sum Models

When two to three models are passed to plot_biomass_data() and type is set to "cumulative" a stacked area plot is produced representing the sum of the models biomass.

plot_biomass_data(dat1 = trout1, dat2 = trout2, type = "cumulative")

Additional Plotting Options

Plotly Plot

The plotly argument can be set to TRYE to output an interactive ggplotly object.

plot_biomass_data(dat1 = trout1, plotly = TRUE)

Title

The title argument can be used to provide a custom title to the plot. If left NULL, a title will automatically be generated.

plot_biomass_data(dat1 = trout1, title = "Trout are cool!")

Y Axis Maximum

The ymax arguement can be used to specify the upper limit for the y axis. If left blank this will be automatically chosen based on the input data.

plot_biomass_data(dat1 = trout1, ymax = 1000)


zac-driscoll/trout.modlR documentation built on March 24, 2022, 10:04 p.m.