diff --git a/NAMESPACE b/NAMESPACE index 48a9429f..e627383e 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -19,7 +19,6 @@ export(problems) export(read_ct_spec) export(read_ct_spec_example) export(read_domain_example) -export(rec_vars) export(sbj_vars) importFrom(rlang,"%||%") importFrom(rlang,":=") diff --git a/R/derive_seq.R b/R/derive_seq.R index 9e64de84..01e9e354 100644 --- a/R/derive_seq.R +++ b/R/derive_seq.R @@ -15,8 +15,7 @@ #' @param tgt_var The target SDTM variable: a single string indicating the name #' of the sequence number (`--SEQ`) variable, e.g. `"DSSEQ"`. Note that #' supplying a name not ending in `"SEQ"` will raise a warning. -#' @param rec_vars A character vector of record-level identifier variables. Use -#' [rec_vars()] to quickly get the identifier variables for a given domain. +#' @param rec_vars A character vector of record-level identifier variables. #' @param sbj_vars A character vector of subject-level identifier variables. #' @param start_at The sequence numbering starts at this value (default is `1`). #' @@ -29,7 +28,8 @@ #' (vs <- read_domain_example("vs")) #' #' # Derivation of VSSEQ -#' derive_seq(tgt_dat = vs, tgt_var = "VSSEQ", rec_vars = rec_vars("VS")) +#' rec_vars <- c("STUDYID", "USUBJID", "VSTESTCD", "VSDTC", "VSTPTNUM") +#' derive_seq(tgt_dat = vs, tgt_var = "VSSEQ", rec_vars = rec_vars) #' #' # An APSC raw data set example #' (apsc <- read_domain_example("apsc")) diff --git a/R/rec_vars.R b/R/rec_vars.R deleted file mode 100644 index 18cb94c6..00000000 --- a/R/rec_vars.R +++ /dev/null @@ -1,37 +0,0 @@ -#' Record-level key variables -#' -#' [rec_vars()] returns the set of variable names that uniquely define -#' a record in a given SDTM domain. -#' -#' @param domain An SDTM domain in abbreviated form, e.g. `"DM"` (Demographics) -#' or `"CM"` (Concomitant Medications). -#' -#' @returns A character vector of variable names. -#' -#' @examples -#' rec_vars("DM") -#' -#' rec_vars("AE") -#' -#' @export -rec_vars <- function(domain) { - - domain <- toupper(domain) - domain <- rlang::arg_match(domain, values = names(domain_record_vars)) - domain_record_vars[[domain]] -} - -#' Subject-level key variables -#' -#' [sbj_vars()] returns the set of variable names that uniquely define -#' a subject. -#' -#' @returns A character vector of variable names. -#' -#' @examples -#' sbj_vars() -#' -#' @export -sbj_vars <- function() { - c("STUDYID", "USUBJID") -} diff --git a/R/sbj_vars.R b/R/sbj_vars.R new file mode 100644 index 00000000..96871eb1 --- /dev/null +++ b/R/sbj_vars.R @@ -0,0 +1,14 @@ +#' Subject-level key variables +#' +#' [sbj_vars()] returns the set of variable names that uniquely define +#' a subject. +#' +#' @returns A character vector of variable names. +#' +#' @examples +#' sbj_vars() +#' +#' @export +sbj_vars <- function() { + c("STUDYID", "USUBJID") +} diff --git a/R/sysdata.rda b/R/sysdata.rda deleted file mode 100644 index 9c1010d3..00000000 Binary files a/R/sysdata.rda and /dev/null differ diff --git a/data-raw/domain_record_vars.R b/data-raw/domain_record_vars.R deleted file mode 100644 index c97a8d3f..00000000 --- a/data-raw/domain_record_vars.R +++ /dev/null @@ -1,19 +0,0 @@ -# Record variables for SDTM domains -# Original file provided by Edgar Manukyan (Roche). -# Context: https://github.com/pharmaverse/sdtm.oak/issues/15 -# Source URL: https://github.com/pharmaverse/sdtm.oak/files/15326343/domain_key_variables.2.csv -# -# Author: Ramiro Magno (Pattern Institute) -# -library(tidyverse) -path <- here::here("data-raw/domain_record_vars.csv.xz") - -tbl <- - readr::read_csv(path, col_names = TRUE, col_types = "cc") |> - dplyr::mutate(key_variables = strsplit(key_variables, "|", fixed = TRUE)) - -domain_record_vars <- setNames(tbl$key_variables, tbl$domain) - -# `domain_record_vars` is an internal data set but can be accessed via -# `rec_vars()`. -usethis::use_data(domain_record_vars, internal = TRUE) diff --git a/data-raw/domain_record_vars.csv.xz b/data-raw/domain_record_vars.csv.xz deleted file mode 100644 index bac3eb0f..00000000 Binary files a/data-raw/domain_record_vars.csv.xz and /dev/null differ diff --git a/man/derive_seq.Rd b/man/derive_seq.Rd index 2e31c8ca..ae65ceae 100644 --- a/man/derive_seq.Rd +++ b/man/derive_seq.Rd @@ -19,8 +19,7 @@ derive_seq( of the sequence number (\code{--SEQ}) variable, e.g. \code{"DSSEQ"}. Note that supplying a name not ending in \code{"SEQ"} will raise a warning.} -\item{rec_vars}{A character vector of record-level identifier variables. Use -\code{\link[=rec_vars]{rec_vars()}} to quickly get the identifier variables for a given domain.} +\item{rec_vars}{A character vector of record-level identifier variables.} \item{sbj_vars}{A character vector of subject-level identifier variables.} @@ -47,7 +46,8 @@ according to grouping variables indicated in \code{rec_vars}. (vs <- read_domain_example("vs")) # Derivation of VSSEQ -derive_seq(tgt_dat = vs, tgt_var = "VSSEQ", rec_vars = rec_vars("VS")) +rec_vars <- c("STUDYID", "USUBJID", "VSTESTCD", "VSDTC", "VSTPTNUM") +derive_seq(tgt_dat = vs, tgt_var = "VSSEQ", rec_vars = rec_vars) # An APSC raw data set example (apsc <- read_domain_example("apsc")) diff --git a/man/rec_vars.Rd b/man/rec_vars.Rd deleted file mode 100644 index 1557c012..00000000 --- a/man/rec_vars.Rd +++ /dev/null @@ -1,25 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/rec_vars.R -\name{rec_vars} -\alias{rec_vars} -\title{Record-level key variables} -\usage{ -rec_vars(domain) -} -\arguments{ -\item{domain}{An SDTM domain in abbreviated form, e.g. \code{"DM"} (Demographics) -or \code{"CM"} (Concomitant Medications).} -} -\value{ -A character vector of variable names. -} -\description{ -\code{\link[=rec_vars]{rec_vars()}} returns the set of variable names that uniquely define -a record in a given SDTM domain. -} -\examples{ -rec_vars("DM") - -rec_vars("AE") - -} diff --git a/man/sbj_vars.Rd b/man/sbj_vars.Rd index 57b04ed6..80f8b5b2 100644 --- a/man/sbj_vars.Rd +++ b/man/sbj_vars.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/rec_vars.R +% Please edit documentation in R/sbj_vars.R \name{sbj_vars} \alias{sbj_vars} \title{Subject-level key variables}