View source: R/glfishr_utils.R
join_fn_fields | R Documentation |
The function join_fn_fields() takes a parent data frame, a child data frame, and a list of fields that you would like get from the parent and add to each record in the child table. The example below adds site depth to each catch count record The '...' is passed through to merge() and to specify left (all.x=TRUE) and right (all.y=T) outer joins to ensure that unmatched records are included in the returned data frame. Child and parent tables don't have to be data frames returned directly from the api - they can be from anywhere, as long as they have the FN-2 key fields.'
join_fn_fields(parent, child, parent_fields, ...)
parent |
the dataframe that contains the fields we would like to add out our target (child) dataframe. |
child |
The dataframe that contains the data we are appending columns to. |
parent_fields |
a vector of field names from the parent data frame that will be added to the child dataframe. |
... |
additional arguments that are passed to merge. Normally all.x=TRUE or all.y=TRUE |
TODO -> verify that common keys uniquely identify one parent record.
dataframe
Adam Cottrill adam.cottrill@ontario.ca
prj_cd <- "LHA_IA10_006"
fn121 <- get_FN121(list(prj_cd = prj_cd))
fn123 <- get_FN123(list(prj_cd = prj_cd, spc = "091"))
# add site depth to each catch count record:
fn123 <- join_fn_fields(fn121, fn123, c("SIDEP0"), all.x = TRUE)
# add gear to the FN121 table:
fn028 <- get_FN028(list(prj_cd = prj_cd))
fn121 <- join_fn_fields(fn028, fn121, c("GR"))
# then add gear and site depth to each catch count record:
fn123 <- join_fn_fields(fn121, fn123, c("GR"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.