R/importOABLengthsCECAF.R

Defines functions importOABLengthsCECAF

Documented in importOABLengthsCECAF

#' Import SIRENO haul report from on-board sampling in the CECAF project.
#'
#' This function import the lengths file obtained from OAB
#' reports in SIRENO on CECAF project. The SIRENO Lengths report must be
#' generated by categories.
#'
#' Multiple files can be imported at the same time.
#'
#' @note The SIRENO Lengths report must be generated by categories.
#' @param file vector with the file names.
#' @param path path of the files. The working directory by default.
#' @return Return data frame.
#' @export
importOABLengthsCECAF <- function(file, path = getwd()){

  file_type <- "OAB_LENGTHS_CECAF"

  lengths <- lapply(
    file,
    importFileFromSireno,
    file_type,
    path
  )

  lengths <- Reduce(rbind, lengths)

  checkStructureFile(lengths, file_type)

  lengths <- renameFileVariables(lengths, file_type)

  # This file has variable with comma as a decimal character: TAMANO_MALLA
  lengths <- replace_coma_with_dot(lengths, "TAMANO_MALLA")

  lengths <- fixCuadriculaICES(lengths)

  lengths <- formatVariableTypes(lengths, file_type)

}
Eucrow/sapmuebase documentation built on April 17, 2024, 10:29 a.m.