lowerTblData: Get lower table data from upper table id

View source: R/lowerTblData.R

lowerTblDataR Documentation

Get lower table data from upper table id

Description

This function takes an upper table field name, values for that field, a list of tables, and a target lower level table name. It returns the rows of the target lower level table that are associated with the given values of the upper table field. NB! running on the RDBESDataObject will work properly if it is sorted by default the tables are not in the correct order for a specific hierarchy.

Usage

lowerTblData(field, values, tbls, level, verbose = FALSE)

Arguments

field

A character string specifying the name of the upper table field.

values

A vector of values for the upper table field.

tbls

A named list of data frames representing the tables.

level

A character string specifying the name of the target lower level table.

verbose

A logical value indicating whether to print intermediate levels during recursion.

Value

A data frame containing the rows of the target lower level table that are associated with the given values of the upper table field.

Examples

# it is important to run the function only on the sorted RDBESDataObject
RDBEScore:::lowerTblData("TEid", c(4), sort(H8ExampleEE1), "SA", TRUE)

DE <- data.table::data.table(DEid = c(1, 2, 3, 4), SDid = c(1, 2, 3, 4))
SD <- data.table::data.table(SDid = c(1, 2, 3, 4), TEid = c(1, 2, 3, 4))
TE <- data.table::data.table(SDid = c(1, 2, 3, 4), TEid = c(1, 2, 3, 4))
VS <- data.table::data.table(TEid = c(1, 2, 3, 4), VSid = c(1, 2, 3, 4))
LE <- data.table::data.table(VSid = 1:5, LEid = 1:5, value = c(10, 20, 3, 4, 6))
tblsSprat <- list( DE = DE ,SD = SD, TE = TE, VS = VS, LE = LE )

RDBEScore:::lowerTblData("TEid", c(4), tblsSprat, "LE", TRUE)

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