--- title: "Scallop Example" output: rmarkdown::html_vignette: fig_width: 6 fig_height: 4 vignette: > %\VignetteIndexEntry{Scallop Example} %\VignetteEngine{knitr::rmarkdown} %\VignetteEncoding{UTF-8} --- ```{r, include = FALSE} knitr::opts_chunk$set( collapse = TRUE, comment = "#>" ) ``` ## Introduction This vignette is an example of an exploratory data analysis using `FishSET`. It utilizes a range of `FishSET` functions for importing and upload data, performing quality assessment/quality control, and summarizing and visualizing data.
## Packages ```{r setup} library(FishSET) library(dplyr) library(tidyr) library(ggplot2) library(maps) ```
## Project Setup The chunk below defines the location of the FishSET Folder. A temporary directory is used in this vignette example; for actual use, set the `folderpath` to a location that is not temporary. ```{r} folderpath <- tempdir() proj <- "scallop" ```
## Data Import Upload the northeast scallop data that is included with the FishSET package. ```{r} load_maindata(dat = FishSET::scallop, project = proj) ``` The northeast scallop dataset is an obscured version of trip-level data from the scallop fishery from 2008-2015. We have retained 10,000 observations from the Limited Access Fishery that were landed at "large" ports. We have added random noise to the point locations, landings, and value. We have also replaced the TRIPID and PERMIT variables with identifiers that cannot be linked to originals. |Column Name | Type | Description | |:------------- |:-------| :---------------------------------| |TRIPID |integer | An identifier variable for a trip (**O**) | |DATE_TRIP |Date | The date of landing (**O**) | PERMIT.y|int | An identifier variable for a vessel. Rows with the same value indicate repeated observations of trips by the same vessel (**O**) | |TRIP_LENGTH| num | length of the trip, in days| |GEARCODE |chr | the type of gear used | |port_lat |num | latitude of the landing port, decimal degrees| |port_lon |num | longitude of the landing port, decimal degrees| |previous_port_lat|num | latitude of the previous landing port, decimal degrees| |previous_port_lon |num | longitude of the previous landing port, decimal degrees| |Plan Code |chr |=SES, indicating these trips are in the Scallop Fishery | |Program Code |chr |=SAA indicates a trip to a scallop access area; =SCA indicates a Limited Access DAYS-at-Sea Trip | |TRIP_COST_WINSOR_2020_DOL | num|Predicted trip costs,in 2020 dollars, winsorized to remove outliers | |DDLAT |num| latitude of fishing location, decimal degrees (**O**) | |DDLON |num| longitude of fishing location, decimal degrees (**O**) | |ZoneID|num | Fishing zone ID that corresponds to the *TEN_ID* variable of the tenMNSQR spatial table | |LANDED_OBSCURED|num |Landed meat weights of scallops, in pounds (**O**) | |DOLLAR_OBSCURED|num |Value of landed scallops, nominal dollars (**O**) | |DOLLAR_2020_OBSCURED|num |Value of landed scallops, 2020 dollars (**O**) | |DOLLAR_ALL_SP_2020_OBSCURED|num |Value of all species landed on a trip, 2020 dollars (**O**) | (**O**) indicates the values in the columns have been obscured.
This data contains `r nrow(scallopMainDataTable)` rows and `r ncol(scallopMainDataTable)` variables.
A commonly used grid in the Northeast United States is the 10 minute grid. Each grid cell is 10' latitude by 10' longitude. This may or may not be the appropriate grid for your research question. Upload and view the ten minute squares map from the FishSET package. ```{r load_and_plot_tens} load_spatial(spat = FishSET::tenMNSQR, project = proj, name = "TenMNSQR") plot_spat(tenMNSQR) ``` We have included the locations of prospective Wind Lease areas in the Northeast United States as of early 2023. These are intended to illustrate FishSET capabilities. Upload and view the WindClose areas from the FishSET package. ```{r load_and_plot_windclose} load_spatial(spat = FishSET::windLease, project = proj, name = "WindClose") plot_spat(windLease) ```
Assign the the 10 minute squares cells (`scallopTenMNSQRSpatTable`) and Wind areas (`scallopWindCloseSpatTable`) to variables for the working environment. ```{r} scallopTenMNSQRSpatTable <- table_view("scallopTenMNSQRSpatTable", proj) scallopWindCloseSpatTable <- table_view("scallopWindCloseSpatTable", proj) ```
### Fleet assignment FishSET can operate on distinct fleets. To do so, create a fleet table and use FishSET's ``fleet_assign'' function. Assign all observations to either "Access Area" or "Days at Sea" fleets. ```{r create_fleet_tabs} fleet_tab <- data.frame( condition = c('`Plan Code` == "SES" & `Program Code` == "SAA"', '`Plan Code` == "SES" & `Program Code` == "SCA"'), fleet = c("Access Area", "Days at Sea")) ``` ```{r} # save fleet table to FishSET DB fleet_table(scallopMainDataTable, project = proj, table = fleet_tab, save = TRUE) # grab tab name fleet_tab_name <- list_tables(proj, type = "fleet") # create fleet column scallopMainDataTable <- fleet_assign(scallopMainDataTable, project = proj, fleet_tab = fleet_tab_name) ```
### Bin Gears The data contain several types of fishing gear. For simplicity, the `GEARCODE` column is re-binned to include three categories: `"DREDGE"`, `"TRAWL-BOTTOM"`, and `"OTHER"`. ```{r bin_gears} scallopMainDataTable$GEARCODE_OLD <- scallopMainDataTable$GEARCODE #Anything with "DREDGE" in the GEARCODE will be rebinned to "DREDGE" pat_match <- "*DREDGE*" reg_pat <- glob2rx(pat_match) scallopMainDataTable$GEARCODE[grep(reg_pat, scallopMainDataTable$GEARCODE)] <- 'DREDGE' #Look at the GEARCODE NOW, there should be 'DREDGE', 'TRAWL-BOTTOM', and some funky stuff table(scallopMainDataTable$GEARCODE) scallopMainDataTable$GEARCODE[!(scallopMainDataTable$GEARCODE %in% c('DREDGE','TRAWL-BOTTOM'))] <- 'OTHER' ```
### Operating Profit Calculate operating profit of a trip by subtracting trip costs from revenues. ```{r calculate operating profit} scallopMainDataTable <- scallopMainDataTable %>% mutate(OPERATING_PROFIT_2020 = DOLLAR_ALL_SP_2020_OBSCURED - TRIP_COST_WINSOR_2020_DOL) ```
### Summary Table FishSET can construct a table of summary statistics. To do so, use FishSET's ``summary_stats'' function. ```{r} summary_stats(scallopMainDataTable, proj) %>% pretty_tab_sb() ```
## QAQC FishSET can do Quality Assurance checks on your data for NA, NaN, duplicates, and formatting. ### NA Check ```{r} na_filter(scallopMainDataTable, project = proj, replace = FALSE, remove = FALSE, rep.value = NA, over_write = FALSE) ``` The ``na_filter()`` shows that some columns have missing values. By setting ``remove=TRUE,`` these can be dropped, although other methods of handling missing data may be better.
### NaN Check ```{r} nan_filter(scallopMainDataTable, project = proj, replace = FALSE, remove = FALSE, rep.value = NA, over_write = FALSE) ``` The ``nan_filter()`` shows the data does not have any NaNs
### Unique Rows ```{r} unique_filter(scallopMainDataTable, project = proj, remove = FALSE) ``` The ``unique_filter()`` shows that all rows are unique.
### Empty Variables "Empty" variables contain only `NA`s. ```{r} empty_vars_filter(scallopMainDataTable, project = proj, remove = FALSE) ``` The ``empty_vars_filter()`` shows that none of the columns are exclusively filled with NAs.
### Lon/Lat Format ```{r} degree(scallopMainDataTable, project = proj, lat = "DDLAT", lon = "DDLON", latsign = NULL, lonsign = NULL, replace = FALSE) ```
### Spatial QAQC FishSET can perform some spatial QAQC. The object ``scallopTenMNSQRSpatTable`` defines areas of the ocean. The ``spatial_qaqc`` function is used to check for rows of data that are on land (not in ``scallopTenMNSQRSpatTable``) and on the boundary between cells. ```{r} spat_qaqc_out <- spatial_qaqc(dat = scallopMainDataTable, project = proj, spat = scallopTenMNSQRSpatTable, lon.dat = "DDLON", lat.dat = "DDLAT") spat_qaqc_out$dataset <- NULL # drop dataset spat_qaqc_out$spatial_summary %>% pretty_lab(cols = "n") %>% pretty_tab() spat_qaqc_out[2:4] ``` There are a few rows where the reported fishing location is on land. There are also a few rows where the fishing location is exactly on the boundary between 10 minute squares. The regular spacing suggests that these points are located on vertices of cells (not the lines connecting the vertices). This is not particularly surprising. Each of the points on a vertex could reasonably be assigned to one of the four cells that share that vertex.
## Data Creation ### Landing Year ```{r} scallopMainDataTable <- scallopMainDataTable %>% mutate(DB_LANDING_YEAR = as.numeric(format(date_parser(DATE_TRIP), "%Y"))) ```
### Scale LANDED_OBSCURED to thousands of pounds Scaling catch data to 'smaller' numbers can often improve model fit and computing efficiency for discrete choice models. ```{r} scallopMainDataTable$LANDED_OBSCURED <- scallopMainDataTable$LANDED_OBSCURED / 1000 ```
### Catch per Unit Effort (CPUE) FishSET can create Catch per Unit Effort variables. Create `CPUE` variable using `TRIP_LENGTH` and `LANDED_OBSCURED`. Filter out any infinite values. ```{r} scallopMainDataTable <- cpue(scallopMainDataTable, proj, xWeight = "LANDED_OBSCURED", xTime = "TRIP_LENGTH", name = "CPUE") scallopMainDataTable <- scallopMainDataTable %>% filter(!is.infinite(CPUE)) ```
#### CPUE Percent Rank Add a percent rank column to filter outliers. ```{r} outlier_table(scallopMainDataTable, proj, x = "CPUE") %>% pretty_lab() %>% pretty_tab() scallopMainDataTable <- scallopMainDataTable %>% mutate(CPUE_p = percent_rank(CPUE)) ```
### Value Per Unit Effort Similar to catch per unit effort, FishSET can create Value (or Revenue) per Unit Effort. Here, we used revenue (`DOLLAR_OBSCURED`) instead of `Landed` ```{r} scallopMainDataTable <- cpue(scallopMainDataTable, proj, xWeight = "DOLLAR_OBSCURED", xTime = "TRIP_LENGTH", name = "VPUE") scallopMainDataTable <- scallopMainDataTable %>% filter(!is.infinite(VPUE)) ```
#### VPUE Percent Rank Add a percent rank column to filter outliers. ```{r} outlier_table(scallopMainDataTable, proj, x = "VPUE") %>% pretty_lab() %>% pretty_tab() scallopMainDataTable <- scallopMainDataTable %>% mutate(VPUE_p = percent_rank(VPUE)) ```
### Fleet Tabulation ```{r} scallopMainDataTable %>% count(fleet) %>% mutate(perc = round(n/sum(n) * 100, 1)) %>% pretty_lab(cols = "n") %>% pretty_tab() ```
### Zone Assignment Assign each observation to a ten minute square. ```{r} scallopMainDataTable <- assignment_column(scallopMainDataTable, project = proj, spat = scallopTenMNSQRSpatTable, lon.dat = "DDLON", lat.dat = "DDLAT", cat = "TEN_ID", name = "ZONE_ID", closest.pt = FALSE, hull.polygon = FALSE) ```
### Closure Area Assignment Assign each observation to a closure area. An observation will have an `NA` if it does not occur within a closure area. ```{r} scallopMainDataTable <- assignment_column(scallopMainDataTable, project = proj, spat = scallopWindCloseSpatTable, lon.dat = "DDLON", lat.dat = "DDLAT", cat = "NAME", name = "closeID", closest.pt = FALSE, hull.polygon = FALSE) scallopMainDataTable <- scallopMainDataTable %>% mutate(in_closure = !is.na(closeID)) ```
`r sum(scallopMainDataTable$in_closure)` observations (`r round(sum(scallopMainDataTable$in_closure)/nrow(scallopMainDataTable) * 100, 2)`%) occurred inside a closure area. ```{r} agg_helper(scallopMainDataTable, value = "in_closure", count = TRUE, fun = NULL) %>% pivot_wider(names_from = "in_closure", values_from = "n") %>% rename("Outside Closure(s)" = "FALSE", "Inside Closure(s)" = "TRUE") %>% pretty_lab() %>% pretty_tab() ```
Observations inside/outside closures by fleet. ```{r} agg_helper(scallopMainDataTable, group = "fleet", value = "in_closure", count = TRUE, fun = NULL) %>% pivot_wider(names_from = "in_closure", values_from = "n") %>% rename("Outside Closure(s)" = "FALSE", "Inside Closure(s)" = "TRUE") %>% pretty_lab() %>% pretty_tab() ```
Observations inside/outside closures by year. ```{r} agg_helper(scallopMainDataTable, value = "in_closure", group = "DB_LANDING_YEAR", count = TRUE, fun = NULL) %>% pivot_wider(names_from = "in_closure", values_from = "n", values_fill = 0) %>% arrange(DB_LANDING_YEAR) %>% rename("Outside closure(s)" = "FALSE", "Inside closure(s)" = "TRUE") %>% pretty_lab(ignore = "DB_LANDING_YEAR") %>% pretty_tab() ```
Observations inside/outside closures by year and fleet. ```{r} agg_helper(scallopMainDataTable, value = "in_closure", group = c("DB_LANDING_YEAR", "fleet"), count = TRUE, fun = NULL) %>% pivot_wider(names_from = "in_closure", values_from = "n", values_fill = 0) %>% arrange(DB_LANDING_YEAR) %>% rename("Outside closure(s)" = "FALSE", "Inside closure(s)" = "TRUE") %>% pretty_lab(ignore = "DB_LANDING_YEAR") %>% pretty_tab_sb(width = "60%") ```
## Zone Summary FishSET's `zone_summary' function can summarize the data by zone (Ten Minute Square) using interactive maps to make exploratory data analysis easier. ### Frequency The number of observations by zone. ```{r} zone_out <- zone_summary(scallopMainDataTable, project = proj, spat = scallopTenMNSQRSpatTable, zone.dat = "ZONE_ID", zone.spat = "TEN_ID", output = "tab_plot", count = TRUE, breaks = NULL, n.breaks = 10, na.rm = TRUE) zone_out$plot zone_out$table %>% pretty_lab(cols = "n") %>% pretty_tab_sb(width = "40%") ```
Percent of observations by zone can be produced by using ``fun="percent"``. ```{r} zone_out <- zone_summary(scallopMainDataTable, project = proj, spat = scallopTenMNSQRSpatTable, zone.dat = "ZONE_ID", zone.spat = "TEN_ID", output = "tab_plot", count = TRUE, fun = "percent", breaks = c(seq(.2, .5, .1), seq(1, 2, .5)), na.rm = TRUE) zone_out$plot zone_out$table %>% pretty_lab(ignore = "ZONE_ID") %>% pretty_tab_sb(width = "40%") ```
``Zone_summary`` can be used in conjunction with ``dplyr::filter`` to produce summaries for just one fleet (Access Area fleet). ```{r} zone_out <- scallopMainDataTable %>% dplyr::filter(fleet == "Access Area") %>% zone_summary(project = proj, spat = scallopTenMNSQRSpatTable, zone.dat = "ZONE_ID", zone.spat = "TEN_ID", output = "tab_plot", count = TRUE, breaks = NULL, n.breaks = 10, na.rm = TRUE) zone_out$plot zone_out$table %>% pretty_lab(cols = "n") %>% pretty_tab_sb(width = "40%") ```
Zone frequency (Days at Sea fleet). ```{r} zone_out <- scallopMainDataTable %>% dplyr::filter(fleet == "Days at Sea") %>% zone_summary(project = proj, spat = scallopTenMNSQRSpatTable, zone.dat = "ZONE_ID", zone.spat = "TEN_ID", output = "tab_plot", count = TRUE, breaks = NULL, n.breaks = 10, na.rm = TRUE) zone_out$plot zone_out$table %>% pretty_lab(cols = "n") %>% pretty_tab_sb(width = "40%") ```
### Catch FishSET's `zone_summary' function be used to aggregate total landings in each zone. ```{r} zone_out <- zone_summary(scallopMainDataTable, project = proj, spat = scallopTenMNSQRSpatTable, zone.dat = "ZONE_ID", zone.spat = "TEN_ID", count = FALSE, var = "LANDED_OBSCURED", fun = "sum", breaks = c(1e3, 1e4, 5e4, 1e5, seq(1e6, 1.3e7, 2e6)), output = "tab_plot", na.rm = TRUE) zone_out$plot zone_out$table %>% pretty_lab(cols = "LANDED_OBSCURED") %>% pretty_tab_sb(width = "40%") ```
FishSET's `zone_summary' function be used to construct average landings for trips in each zone. ```{r} zone_out <- zone_summary(scallopMainDataTable, project = proj, spat = scallopTenMNSQRSpatTable, zone.dat = "ZONE_ID", zone.spat = "TEN_ID", count = FALSE, var = "LANDED_OBSCURED", fun = "mean", breaks = c(1e3, 5e3, seq(1e4, 4e4, 5e3)), output = "tab_plot", na.rm = TRUE) zone_out$plot zone_out$table %>% pretty_lab(cols = "LANDED_OBSCURED") %>% pretty_tab_sb(width = "40%") ```
Using the ``fun="percent"`` option computes the percent of total landings. ```{r} zone_out <- zone_summary(scallopMainDataTable, project = proj, spat = scallopTenMNSQRSpatTable, zone.dat = "ZONE_ID", zone.spat = "TEN_ID", count = FALSE, var = "LANDED_OBSCURED", fun = "percent", breaks = seq(0, 2, .2), bin_colors = c("white", fishset_viridis(10)), output = "tab_plot", na.rm = TRUE) zone_out$plot zone_out$table %>% pretty_lab(cols = c("LANDED_OBSCURED", "LANDED_OBSCURED_perc"), type = "scientific") %>% pretty_tab_sb(width = "60%") ```
### Trip Length Average trip length for Access Area and Days at Sea fleets combined ```{r} zone_out <- zone_summary(scallopMainDataTable, project = proj, spat = scallopTenMNSQRSpatTable, zone.dat = "ZONE_ID", zone.spat = "TEN_ID", count = FALSE, var = "TRIP_LENGTH", fun = "mean", breaks = seq(2, 16, 2), output = "tab_plot", na.rm = TRUE) zone_out$plot zone_out$table %>% pretty_lab(cols = "TRIP_LENGTH", type = "decimal") %>% pretty_tab_sb(width = "40%") ```
### CPUE Average CPUE for Access Area and Days at Sea fleets combined ```{r} zone_out <- scallopMainDataTable %>% filter(CPUE_p >= .025 & CPUE_p <= .975) %>% zone_summary(project = proj, spat = scallopTenMNSQRSpatTable, zone.dat = "ZONE_ID", zone.spat = "TEN_ID", count = FALSE, var = "CPUE", fun = "mean", na.rm = TRUE, output = "tab_plot") zone_out$plot zone_out$table %>% pretty_lab(cols = "CPUE") %>% pretty_tab_sb(width = "50%") ```
### VPUE Average VPUE for Access Area and Days at Sea fleets combined ```{r} zone_out <- scallopMainDataTable %>% filter(VPUE_p >= .025 & VPUE_p <= .975) %>% zone_summary(project = proj, spat = scallopTenMNSQRSpatTable, zone.dat = "ZONE_ID", zone.spat = "TEN_ID", count = FALSE, var = "VPUE", fun = "mean", breaks = seq(5e3, 3.5e4, 5e3), na.rm = TRUE, output = "tab_plot") zone_out$plot zone_out$table %>% pretty_lab(cols = "VPUE") %>% pretty_tab_sb(width = "50%") ```
## Other Spatial Units The ``zone_summary`` function can be used on any spatial unit (``spat``) . By setting ``spat = scallopWindCloseSpatTable,`` the exploratory data analysis of trips inside the Wind polygons can be performed. Number of observations in the Wind areas. ```{r} zone_out <- zone_summary(scallopMainDataTable, project = proj, spat = scallopWindCloseSpatTable, zone.dat = "closeID", zone.spat = "NAME", count = TRUE, na.rm = TRUE, dat.center = FALSE, output = "tab_plot") zone_out$table %>% pretty_lab() %>% pretty_tab_sb(width = "40%") zone_out$plot ```
Percent of observations in Wind areas. ```{r} zone_out <- zone_summary(scallopMainDataTable, project = proj, spat = scallopWindCloseSpatTable, zone.dat = "closeID", zone.spat = "NAME", fun = "percent", count = TRUE, na.rm = TRUE, dat.center = FALSE, output = "tab_plot") zone_out$table %>% pretty_lab() %>% pretty_tab_sb(width = "40%") zone_out$plot ```
Percent of total revenue by Wind area. ```{r} zone_out <- zone_summary(scallopMainDataTable, project = proj, spat = scallopWindCloseSpatTable, zone.dat = "closeID", zone.spat = "NAME", var = "DOLLAR_OBSCURED", fun = "percent", count = FALSE, na.rm = TRUE, dat.center = FALSE, output = "tab_plot") zone_out$table %>% pretty_lab() %>% pretty_tab_sb(width = "70%") zone_out$plot ```
Percent of total revenue by fleet can be constructed using the ``group="fleet"`` argument. ```{r} zone_out <- zone_summary(scallopMainDataTable, project = proj, spat = scallopWindCloseSpatTable, zone.dat = "closeID", zone.spat = "NAME", var = "DOLLAR_OBSCURED", group = "fleet", fun = "percent", count = FALSE, na.rm = TRUE, dat.center = FALSE, output = "tab_plot") zone_out$table %>% pretty_lab() %>% pretty_tab_sb(width = "70%") zone_out$plot ```
Average meat catch per closure area. ```{r} zone_out <- zone_summary(scallopMainDataTable, project = proj, spat = scallopWindCloseSpatTable, zone.dat = "closeID", zone.spat = "NAME", var = "LANDED_OBSCURED", fun = "mean", count = FALSE, na.rm = TRUE, dat.center = FALSE, output = "tab_plot") zone_out$table %>% pretty_lab() %>% pretty_tab_sb(width = "50%") zone_out$plot ```
Average meat catch by fleet. ```{r} zone_out <- zone_summary(scallopMainDataTable, project = proj, spat = scallopWindCloseSpatTable, zone.dat = "closeID", zone.spat = "NAME", var = "LANDED_OBSCURED", group = "fleet", fun = "mean", count = FALSE, na.rm = TRUE, dat.center = FALSE, output = "tab_plot") zone_out$table %>% pretty_lab() %>% pretty_tab_sb(width = "60%") zone_out$plot ```
## Outliers FishSET has some functionality to detect outliers, and remove if necessary. ### POUNDS ```{r} outlier_table(scallopMainDataTable, proj, x = "LANDED_OBSCURED") %>% pretty_lab() %>% pretty_tab() ``` ```{r} outlier_plot(scallopMainDataTable, proj, x = "LANDED_OBSCURED", dat.remove = "none", x.dist = "normal", output.screen = TRUE) ``` ```{r} outlier_plot(scallopMainDataTable, proj, x = "LANDED_OBSCURED", dat.remove = "mean_3SD", x.dist = "normal", output.screen = TRUE) ```
## Temporal Plots FishSET can plot variables over time. ```{r} temp_plot(scallopMainDataTable, proj, var.select = "LANDED_OBSCURED", len.fun = "percent", agg.fun = "sum", date.var = "DATE_TRIP", pages = "multi") ``` This plot reveals some seasonality in the Landed pounds.
```{r} temp_plot(scallopMainDataTable, proj, var.select = "TRIP_LENGTH", len.fun = "percent", agg.fun = "sum", date.var = "DATE_TRIP", pages = "multi") ```
```{r} temp_plot(scallopMainDataTable, proj, var.select = "DOLLAR_OBSCURED", len.fun = "percent", agg.fun = "sum", date.var = "DATE_TRIP", pages = "multi") ```
## Scatter Plots Trip length by meat catch. ```{r} xy_plot(scallopMainDataTable, proj, var1 = "TRIP_LENGTH", var2 = "LANDED_OBSCURED", regress = FALSE, alpha = .3) ```
Trip length by revenue. ```{r} xy_plot(scallopMainDataTable, proj, var1 = "TRIP_LENGTH", var2 = "DOLLAR_OBSCURED", regress = FALSE, alpha = .3) ```
Trip length by trip cost (Winsor). ```{r} xy_plot(scallopMainDataTable, proj, var1 = "TRIP_LENGTH", var2 = "TRIP_COST_WINSOR_2020_DOL", regress = FALSE, alpha = .3) ``` The winsorization of trip costs is apparent in the horizontal line of points just over $30,000.
## Correlation Matrix A simple table of two-way correlations can be illuminative. ```{r fig.width=8.5, fig.height=6.5} corr_outs <- corr_out(scallopMainDataTable, proj, variables = "all", method = "pearson", show_coef = FALSE) corr_outs$plot corr_outs$table %>% pretty_tab_sb(width = "100%") ``` Note the strong correlation between ``TRIP_LENGTH`` and the ``TRIP_COST_WINSOR`` variables. This is because Trip costs are predicted from a statistical relationship between Trip length and costs on a subset of observed trips. There also is a moderate correlation between ``port_lat`` and ``previous_port_lat.`` This occurs because trips usually use 1 port.
## Active Vessels Vessel count by year. ```{r} ves_out <- vessel_count(scallopMainDataTable, proj, v_id = "PERMIT.y", date = "DATE_TRIP", period = "year", type = "line") ves_out$table %>% pretty_tab() ves_out$plot ```
Vessel count by fleet. ```{r} ves_out <- vessel_count(scallopMainDataTable, proj, v_id = "PERMIT.y", group = "fleet", output = "table") ves_out$table %>% pretty_tab() ves_out$plot ```
Vessel count by year and fleet. ```{r} ves_out <- vessel_count(scallopMainDataTable, proj, v_id = "PERMIT.y", group = "fleet", date = "DATE_TRIP", period = "year", type = "line") ves_out$table %>% pretty_lab(cols = "PERMIT.y") %>% pretty_tab_sb(width = "40%") ves_out$plot ```
vessel count by gearcode. ```{r} ves_out <- vessel_count(scallopMainDataTable, proj, v_id = "PERMIT.y", group = "GEARCODE", tran = "log") ves_out$table %>% pretty_lab() %>% pretty_tab() ves_out$plot ```
## Catch Total meat catch by year. ```{r} catch_out <- species_catch(scallopMainDataTable, proj, species = "LANDED_OBSCURED", date = "DATE_TRIP", period = "year", fun = "sum", type = "line", format_lab = "decimal") catch_out$table %>% pretty_lab(cols = "LANDED_OBSCURED") %>% pretty_tab() catch_out$plot ```
Total meat catch by fleet. ```{r} catch_out <- species_catch(scallopMainDataTable, proj, species = "LANDED_OBSCURED", group = "fleet", fun = "sum", type = "bar", format_lab = "decimal") catch_out$table %>% pretty_lab(cols = "LANDED_OBSCURED") %>% pretty_tab() catch_out$plot ```
Total meat catch by year and fleet. ```{r} catch_out <- species_catch(scallopMainDataTable, proj, species = "LANDED_OBSCURED", date = "DATE_TRIP", period = "year", group = "fleet", fun = "sum", type = "line", format_lab = "decimal") catch_out$table %>% pretty_lab(cols = "LANDED_OBSCURED") %>% pretty_tab_sb(width = "40%") catch_out$plot ```
## CPUE Average CPUE by year. ```{r} cpue_out <- species_catch(scallopMainDataTable, proj, species = "CPUE", date = "DATE_TRIP", period = "year", fun = "mean", type = "line") cpue_out$table %>% pretty_lab(cols = "CPUE") %>% pretty_tab() cpue_out$plot ```
Average CPUE by year and fleet. ```{r} cpue_out <- species_catch(scallopMainDataTable, proj, species = "CPUE", date = "DATE_TRIP", period = "year", group = "fleet", fun = "mean", type = "line") cpue_out$table %>% pretty_lab(cols = "CPUE") %>% pretty_tab_sb(width = "40%") cpue_out$plot ```
## VPUE Average VPUE by year. ```{r} vpue_out <- species_catch(scallopMainDataTable, proj, species = "VPUE", date = "DATE_TRIP", period = "year", fun = "mean", type = "line") vpue_out$table %>% pretty_lab(cols = "VPUE") %>% pretty_tab() vpue_out$plot ```
Average VPUE by year and fleet. ```{r} vpue_out <- species_catch(scallopMainDataTable, proj, species = "VPUE", date = "DATE_TRIP", period = "year", group = "fleet", fun = "mean", type = "line") vpue_out$table %>% pretty_lab(cols = "VPUE") %>% pretty_tab_sb(width = "40%") vpue_out$plot ```
Average VPUE by gearcode. ```{r} vpue_out <- species_catch(scallopMainDataTable, proj, species = "VPUE", group = "GEARCODE", fun = "mean", type = "line") vpue_out$table %>% pretty_lab() %>% pretty_tab() vpue_out$plot + angled_theme() ```
## Distributions FishSET can make various distributional plots ### LANDED_OBSCURED KDE, ECDF, and CDF of meat catch, note the ``tran= "log"`` option to do a log transformation of ``LANDED_OBSCURED.`` ```{r} density_plot(scallopMainDataTable, proj, var = "LANDED_OBSCURED", type = "all", tran = "log") ```

KDE, ECDF, and CDF of meat catch by fleet can be easily produced using the ``group="fleet"`` option. ```{r} density_plot(scallopMainDataTable, proj, var = "LANDED_OBSCURED", group = "fleet", position = "stack", type = "all", tran = "log", pages = "multi") ```
KDE of meat catch by year. ```{r} density_plot(scallopMainDataTable, proj, var = "LANDED_OBSCURED", facet_by = "DB_LANDING_YEAR", filter_by = "DB_LANDING_YEAR", filter_value = 2007:2013, type = "kde", bw = 1.5, tran = "log", scale = "free_y") + angled_theme() density_plot(scallopMainDataTable, proj, var = "LANDED_OBSCURED", facet_by = "DB_LANDING_YEAR", filter_by = "DB_LANDING_YEAR", filter_value = 2014:2019, type = "kde", bw = 1.5, tran = "log", scale = "free_y") + angled_theme() ``` ```{r echo = FALSE} unlink(folderpath) ```