Skip to contents

Check that AirDAS file has accepted formatting and values

Usage

airdas_check(
  file,
  file.type = c("turtle", "caretta", "phocoena"),
  skip = 0,
  file.out = NULL,
  sp.codes = NULL,
  print.transect = TRUE
)

Arguments

file

filename(s) of one or more AirDAS files

file.type

character; indicates the program used to create file. Must be one of: "turtle", "caretta", "survey", or "phocoena" (case sensitive). Default is "turtle". Passed to airdas_read

skip

integer: see read_fwf. Default is 0. Passed to airdas_read

file.out

character; filename to which to write the error log. Should be a text or CSV file. Default is NULL

sp.codes

character; filename of .dat file from which to read accepted species codes. If NULL, default (internal) file will be used. Default is NULL

print.transect

logical; indicates if a table with all the transect numbers in the x should be printed using table. Default is TRUE

Value

A data frame with five columns that list information about errors found in the AirDAS files: the file name, line number, index (row number) from the airdas_read(file) data frame, 'ID' (pre-Data# columns from the DAS file), and description of the issue. This data frame is sorted by the 'Description' column. If there are multiple issues with the same line, the issue descriptions are concatenated together using paste(..., collapse = "; ")

If print.transect is TRUE, then the output of table(x$Data1[x$Event == "T"], useNA = "always"), where x is the output of airdas_read(file, ...) is printed

If file.out is not NULL, then the error log is also written to the file (e.g., a .txt or .csv file) specified by file.out

Details

The default (internal) sp.codes file is located at system.file("SpCodesAirDAS.dat", package = "swfscAirDAS").

To see the checks performed by this function, you can access the PDF locally at system.file("AirDAS_check.pdf", package = "swfscAirDAS"), or online at https://github.com/swfsc/swfscAirDAS/blob/master/inst/AirDAS_check.pdf

Checks that are not done by this function that may be of interest:

  • Check for valid fish ball/mola/jelly/crab pot codes

  • Check that datetimes are sequential, meaning they 1) are the same as or 2) come after the previous event

Examples

y <- system.file("airdas_sample.das", package = "swfscAirDAS")
if (interactive()) airdas_check(y, print.transect = TRUE)