Skip to content

Commit

Permalink
#2609: added example to derive_vars_transposed showcasing duplicates …
Browse files Browse the repository at this point in the history
…error
  • Loading branch information
manciniedoardo committed Feb 18, 2025
1 parent 059406e commit 84a23bb
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

## Documentation

- Added an example to the `derive_vars_transposed()` reference page to showcase how duplicates-related errors can arise when records in `dataset_merge` are not uniquely identified. (#2609)

## Various

<details>
Expand Down
17 changes: 17 additions & 0 deletions R/derive_vars_transposed.R
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
#' library(tibble)
#' library(dplyr, warn.conflicts = FALSE)
#'
#' # Adding ATC classes to CM using FACM
#' cm <- tribble(
#' ~USUBJID, ~CMGRPID, ~CMREFID, ~CMDECOD,
#' "BP40257-1001", "14", "1192056", "PARACETAMOL",
Expand Down Expand Up @@ -96,6 +97,22 @@
#' value_var = FASTRESC
#' ) %>%
#' select(USUBJID, CMDECOD, starts_with("CMATC"))
#'
#' # Note: the id_vars argument here is key to uniquely identify
#' # rows of dataset_merge and avoid duplicates-related errors.
#' # Compare the above call with:
#'
#' cm %>%
#' derive_vars_transposed(
#' facm,
#' by_vars = exprs(USUBJID, CMREFID = FAREFID),
#' id_vars = NULL,
#' key_var = FATESTCD,
#' value_var = FASTRESC
#' )
#'
#' get_duplicates_dataset()
#'
derive_vars_transposed <- function(dataset,
dataset_merge,
by_vars,
Expand Down
17 changes: 17 additions & 0 deletions man/derive_vars_transposed.Rd

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

0 comments on commit 84a23bb

Please sign in to comment.