is_valid_m_key: Check whether specified "many" relationship is valid

View source: R/checks.R

is_valid_m_keyR Documentation

Check whether specified "many" relationship is valid

Description

When "many" relationship is specified, check if it is valid.
(Specified many relationship not valid if the dt is instead uniquely identified by specified keys)

Usage

is_valid_m_key(dt, by)

Arguments

dt

data object

by

character vector: specified keys, already fixed

Value

logical: TRUE if valid, FALSE if uniquely identified

Examples

## Not run: 
# example with data frame uniquely identified by specified `by` vars
x1 = data.frame(id  = c(1L, 1L, 2L, 3L, NA_integer_),
                 t  = c(1L, 2L, 1L, 2L, NA_integer_),
                 x  = 11:15)

joyn:::is_valid_m_key(x1, by = c("id", "t"))
# example with valid specified "many" relationship
x2 = data.frame(id  = c(1L, 1L, 1L, 3L, NA_integer_),
                 t  = c(1L, 2L, 1L, 2L, NA_integer_),
                 x  = 11:15)
joyn:::is_valid_m_key(x2, by = c("id", "t"))

## End(Not run)

randrescastaneda/joyn documentation built on Dec. 20, 2024, 6:51 a.m.