filterAndTidyRDBESDataObject: Filter and remove orphan records in an RDBESDataObject

View source: R/filterAndTidyRDBESDataObject.R

filterAndTidyRDBESDataObjectR Documentation

Filter and remove orphan records in an RDBESDataObject

Description

This function filters an RDBESDataObject based on specified fields and values, and can optionally remove any orphan records. The returned object will include all rows which either: a) do not include any of the field names in fieldsToFilter, or b) do include the field names and have one of the allowed values in valuesToFilter. If killOrphans is set to TRUE, the function will remove orphaned rows. The default is TRUE.

Usage

filterAndTidyRDBESDataObject(
  RDBESDataObjectToFilterAndTidy,
  fieldsToFilter,
  valuesToFilter,
  killOrphans = TRUE,
  verbose = FALSE,
  strict = TRUE
)

Arguments

RDBESDataObjectToFilterAndTidy

The RDBESDataObject to filter.

fieldsToFilter

A vector of the field names you wish to check.

valuesToFilter

A vector of the field values you wish to filter for.

killOrphans

Controls if orphan rows are removed. Default is TRUE.

verbose

(Optional) Set to TRUE if you want informative text printed out, or FALSE if you don't. The default is FALSE.

strict

(Optional) This function validates its input data - should the validation be strict? The default is TRUE.

Value

The filtered input object of the same class as RDBESDataObjectToFilterAndTidy.

Examples

## Not run: 

myH1RawObject <- createRDBESDataObject(rdbesExtractPath = "tests\\testthat\\h1_v_1_19_13")

# To check how removeBrokenVesselLinks() works
myH1RawObject$VD$VDlenCat[which(myH1RawObject$VD$VDencrVessCode=="VDcode_10")] <- "VL40XX"

myFields <- c("VSencrVessCode", "VDlenCat")
myValues <- c("VDcode_1","VDcode_2", "VDcode_10","VL1518","VL2440")

myFilteredObject <- filterAndTidyRDBESDataObject(myH1RawObject,
  fieldsToFilter = myFields,
  valuesToFilter = myValues,
  killOrphans = TRUE, verboseBrokenVesselLinks = TRUE
)

## End(Not run)

ices-tools-dev/icesRDBES documentation built on April 17, 2025, 1:58 p.m.