Skip to contents

Checks that observed captures dataset has the (minimum) variables required for data preparation:

  • flag - an ISO 3166-1 alpha-3 compliant country code, e.g., "NZL" (character);

  • year - calendar year (integer);

  • month - month (integer);

  • lat and lon - latitude and longitude (decimal degrees - numeric), or geometry - a simple feature collection (class sfc);

  • code - a three-letter 'species' code (character - see sp_groups$code for a set of bioligical inputsinputsBio);

  • status - status of captures at-vessel ("alive"), "dead" or NA for unknown);

  • age_class - age-class of captures ("adult"), "immature", "juvenile" or NA for unknown);

  • n_captures - number of individuals (integer or numeric).

If the function output is assigned then the returned object will contain additional data grooming steps:

  • NA values in code are removed;

  • NA or zero values in n_captures are removed.

The User should additionally ensure that the observed captures dataset is filtered to include only captures from strata with available observed effort, e.g., if information for required minimum variables was missing for a strata. An example of this process is provided in the make_inputs vignette: vignette("make_inputs", package = "sefraInputs").

Usage

check_observed_captures(data)

Arguments

data

object to check

Value

If assigned, returns an object of class class(data), with data grooming to exclude missing values in required fields.

Examples

library(sefraInputs)
library(dplyr)
x <- data.frame(
  flag = c(NA, rep("NZL", times = 19)), year = sample(2015:2020, size = 20, replace = TRUE),
  month = sample(1:12, size = 20, replace = TRUE),
  lat = sample(-(35:40), size = 20, replace = TRUE), lon = sample(100:140, size = 20, replace = TRUE),
  code = sample(c("DIW", "PRK", "PRO"), size = 20, replace = TRUE),
  status = sample(c("alive", "dead", NA), size = 20, replace = TRUE),
  age_class = sample(c("adult", "immature", NA), size = 20, replace = TRUE),
  n_captures = sample(0:5, size = 20, replace = TRUE))
# check structure of x:
check_observed_captures(x)
# check structure of x with additional data grooming:
x_groomed <- check_observed_captures(x)
nrow(x); nrow(x_groomed)
#> [1] 20
#> [1] 17