View source: R/check_swept_area.r
| check_swept_area | R Documentation |
Performs data validation and swept area calculation for MEDITS TA-format data. The function verifies numeric consistency in key columns, computes mean depth and swept area, logs any detected issues, and generates a plot of swept area versus mean depth for visual inspection.
check_swept_area(ResultDataTA, year, wd, suffix)
ResultDataTA |
A data.frame containing MEDITS hauls data in TA-format. The function uses the following columns: |
year |
Numeric scalar. The year to be checked in the dataset. |
wd |
Character string. Path to the working directory where log files and plots will be saved. |
suffix |
Character string. Optional suffix to append to the output filenames. If NULL, a timestamp-based suffix is automatically generated. |
This function performs multiple validation steps on TA-format data for MEDITS hauls. It verifies that certain key columns contain numeric values and checks for missing or empty entries in critical fields such as WING_OPENING and DISTANCE.
For each haul, it calculates the mean depth as the average of SHOOTING_DEPTH and HAULING_DEPTH, and estimates the swept area in square kilometers using the formula (WING\_OPENING / 10) \times DISTANCE / 10^6. Any inconsistencies or errors encountered during these checks are written to a logfile stored in the Logfiles folder.
If the data contains valid entries, the function generates and saves a scatter plot showing the swept area against mean depth. The plot includes a background shading to visually separate the depth range 0-200 meters from deeper strata, assisting in the interpretation of data distribution across depth zones.
All output files are organized within subfolders named Logfiles and Graphs under the specified working directory.
A logical value:
TRUE if no errors were detected in the data.
FALSE if at least one error was found and logged.
W. Zupa
# Define working directory
wd <- tempdir()
# Load data
ResultDataTA <- RoME::TA
# Filter for specific area if needed
ResultDataTA <- ResultDataTA[ResultDataTA$AREA == 18, ]
# Run the check for year 2005
check_swept_area(ResultDataTA, year = 2005, wd = wd, suffix = NULL)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.