Skip to content

Commit

Permalink
docs: missed 1 exported function
Browse files Browse the repository at this point in the history
  • Loading branch information
averissimo committed Nov 2, 2023
1 parent 9b57e74 commit 9fb6964
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 48 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export("col_labels<-")
export("data_label<-")
export("datanames<-")
export("get_join_keys<-")
export("join_keys<-")
export("parents<-")
export(as_cdisc)
export(callable_code)
Expand Down
36 changes: 16 additions & 20 deletions R/join_keys.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
#'
#' @details Note that join keys are symmetric although the relationship only needs
#' to be specified once.
#
#'
#' @name join_keys
#'
#' @param ... optional, a `JoinKeySet` objects created using the `join_key` function.
#'
#' @return `JoinKeys`
Expand Down Expand Up @@ -48,33 +50,31 @@ join_keys <- function(...) {
res
}

#' @details
#' The setter assignment `join_keys() <- ...` will only work for an empty
#' `JoinKey` object, otherwise `mutate_join_keys()` must be used.
#' @rdname join_keys
#' @details
#' The setter assignment `join_keys(obj) <- ...` will merge obj and `...` if obj
#' is not empty.
#'
#' @param join_keys_obj (`JoinKeys`) empty object to set the new relationship pairs.
#' @param value (`JoinKeySet` or list of `JoinKeySet`) relationship pairs to add
#' to `JoinKeys` list.
#'
#' @export
`join_keys<-` <- function(join_keys_obj, value) {
UseMethod("join_keys<-", join_keys_obj)
}

#' @details
#' The setter assignment `join_keys() <- ...` will only work for an empty
#' `JoinKey` object, otherwise `mutate_join_keys()` must be used.
#'
#' @rdname join_keys
#' @export
#' @examples
#'
#' # Using the setter (assignment) ----
#'
#' jk <- join_keys()
#' join_keys(jk)
#' join_keys(jk) <- join_key("ds1", "ds2", "some_col")
#' join_keys(jk) <- join_key("ds3", "ds4", "some_col2")
#' join_keys(jk)["ds1", "ds3"] <- "some_col3"
#' jk
`join_keys<-.JoinKeys` <- function(join_keys_obj, value) {
if (missing(value)) {
return(join_keys_obj)
Expand Down Expand Up @@ -121,6 +121,7 @@ join_keys <- function(...) {
#' join_keys(td)["ds1", "ds2"] <- "key1"
#' join_keys(td)["ds2", "ds2"] <- "key2"
#' join_keys(td)["ds3", "ds2"] <- "key3"
#' join_keys(td)
`join_keys<-.teal_data` <- function(join_keys_obj, value) {
if (missing(value)) {
return(join_keys_obj)
Expand All @@ -135,11 +136,10 @@ join_keys <- function(...) {
join_keys_obj
}

#' @rdname join_keys
#' @details
#' Getter for JoinKeys that returns the relationship between pairs of datasets.
#'
#' @rdname join_keys
#'
#' @param join_keys_obj (`JoinKeys`) object to extract the join keys
#' @param dataset_1 (`character`) name of first dataset.
#' @param dataset_2 (`character`) name of second dataset.
Expand Down Expand Up @@ -185,12 +185,11 @@ join_keys <- function(...) {
result
}

#' @rdname join_keys
#' @details
#' Setter via index directly (bypassing the need to use `join_key()`).
#' When `dataset_2` is omitted, it will create a primary key with `dataset_2 = dataset_1`.
#'
#' @rdname join_keys
#'
#' @param value (`character` vector) value to assign.
#'
#' @export
Expand All @@ -216,7 +215,6 @@ join_keys <- function(...) {
join_keys_obj
}

# wrappers ====
#' Mutate `JoinKeys` with a new values
#'
#' @description `r lifecycle::badge("experimental")`
Expand All @@ -241,7 +239,7 @@ mutate_join_keys <- function(x, dataset_1, dataset_2, value) {
#' # JoinKeys ----
#'
#' jk <- join_keys()
#' join_keys(jk) <- list(ds1 = list(ds2 = "some_col"))
#' join_keys(jk) <- join_key("ds1", "ds2", "some_col")
#' mutate_join_keys(jk, "ds2", "ds3", "another")
mutate_join_keys.JoinKeys <- function(x, dataset_1, dataset_2, value) {
checkmate::assert_string(dataset_1)
Expand Down Expand Up @@ -278,6 +276,7 @@ mutate_join_keys.JoinKeys <- function(x, dataset_1, dataset_2, value) {
#' join_keys(x)["ADSL", "ADRS"]
#'
#' join_keys(x) <- mutate_join_keys(x, "ADSL", "ADRS", c("COLUMN1" = "COLUMN2"))
#' join_keys(x)["ADSL", "ADRS"]
mutate_join_keys.teal_data <- function(x, dataset_1, dataset_2, value) { # nolint
join_keys(x) <- mutate_join_keys(join_keys(x), dataset_1, dataset_2, value)
join_keys(x)
Expand Down Expand Up @@ -504,11 +503,7 @@ add_key <- function(join_keys_obj, dataset_1, dataset_2 = dataset_1, value) {
#' @param join_keys_obj (`JoinKeys`) Object with existing pairs.
#' @param join_key_obj (`JoinKeySet`) relationship pair to add.
#'
#' @examples
#' jk <- join_keys()
#' jk <- join_pair(jk, join_key("ds1", "ds2", "value"))
#' jk <- join_pair(jk, join_key("ds3", "ds2", "value"))
#' jk
#' @keywords internal
join_pair <- function(join_keys_obj, join_key_obj) {
assert_join_keys(join_keys_obj)
checkmate::assert_class(join_key_obj, "JoinKeySet")
Expand Down Expand Up @@ -590,6 +585,7 @@ assert_compatible_keys <- function(join_key_1, join_key_2) {
#'
#' @return `join_keys_obj` invisibly
#'
#' @keywords internal
assert_parent_child <- function(join_keys_obj) {
jk <- join_keys(join_keys_obj)
jk_parents <- parents(jk)
Expand Down
12 changes: 6 additions & 6 deletions R/parents.R
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,17 @@ parents.JoinKeys <- function(join_keys_obj) {
#' @examples
#' jk <- join_keys()
#' parents(jk) <- list(ds1 = "ds2", "ds3" = "ds4")
#' parents(jk)["ADTTE"] <- "ADSL"
#' parents(jk)["ADTTE"] <- "ADSL2"
#' parents(jk)["ds5"] <- "ds6"
#' parents(jk)["ds6"] <- "ds7"
`parents<-.JoinKeys` <- function(join_keys_obj, value) {
if (missing(value)) {
return(join_keys_obj)
}
checkmate::assert_list(value, types = "character", names = "named", min.len = 1)
new_parents <- attr(join_keys_obj, "__parents__")
old_parents <- attr(join_keys_obj, "__parents__")

for (dataset in names(value)) {
parent <- new_parents[[dataset]]
parent <- old_parents[[dataset]]
checkmate::assert(
checkmate::check_null(parent),
checkmate::check_true(
Expand All @@ -77,10 +77,10 @@ parents.JoinKeys <- function(join_keys_obj) {
"Please check the difference between provided datasets parents and provided join_keys parents."
)
if (is.null(parent)) {
new_parents[[dataset]] <- value[[dataset]]
old_parents[[dataset]] <- value[[dataset]]
}
}
attr(join_keys_obj, "__parents__") <- new_parents
attr(join_keys_obj, "__parents__") <- old_parents
join_keys_obj
}

Expand Down
1 change: 1 addition & 0 deletions man/assert_parent_child.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 9 additions & 11 deletions man/join_keys.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 1 addition & 6 deletions man/join_pair.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions man/mutate_join_keys.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/parents.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 9fb6964

Please sign in to comment.