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 FALSE.

filterAndTidyRDBESDataObject(
  RDBESDataObjectToFilterAndTidy,
  fieldsToFilter,
  valuesToFilter,
  killOrphans = FALSE,
  verboseOrphans = FALSE,
  verboseBrokenVesselLinks = FALSE
)

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 FALSE.

verboseOrphans

Controls if verbose output for orphan rows is printed. Default is FALSE.

verboseBrokenVesselLinks

Controls if verbose output for broken vessel links is printed. Default is FALSE.

Value

The filtered input object of the same class as RDBESDataObjectToFilterAndTidy.

Examples

if (FALSE) {

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
)
}