generated from pharmaverse/admiraltemplate
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'devel' into 43_codeowners@devel
- Loading branch information
Showing
51 changed files
with
462 additions
and
264 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
#' An example function as expected by the `get_terms_fun` parameter of | ||
#' `admiral::create_query_data()` | ||
#' | ||
#' @param basket_select A basket_select object defining the terms | ||
#' | ||
#' @param version MedDRA version | ||
#' | ||
#' @param keep_id Should `GRPID` be included in the output? | ||
#' | ||
#' @param temp_env Temporary environment | ||
get_terms <- function(basket_select, | ||
version, | ||
keep_id, | ||
temp_env) { | ||
if (basket_select$type == "smq") { | ||
if (is.null(temp_env$smq_db)) { | ||
data("smq_db", envir = temp_env) | ||
} | ||
if (!is.null(basket_select$name)) { | ||
is_in_smq <- temp_env$smq_db$smq_name == basket_select$name | ||
} else { | ||
is_in_smq <- temp_env$smq_db$smq_id == basket_select$id | ||
} | ||
if (basket_select$scope == "NARROW") { | ||
is_in_scope <- temp_env$smq_db$scope == "narrow" | ||
} else { | ||
is_in_scope <- rep(TRUE, nrow(temp_env$smq_db)) | ||
} | ||
if (keep_id) { | ||
select_id <- c(GRPID = "smq_id") | ||
} else { | ||
select_id <- NULL | ||
} | ||
keep_cols <- c( | ||
TERMNAME = "termname", | ||
SRCVAR = "termvar", | ||
GRPNAME = "smq_name", | ||
select_id | ||
) | ||
|
||
structure( | ||
temp_env$smq_db[is_in_smq & is_in_scope, keep_cols], | ||
names = names(keep_cols) | ||
) | ||
} else if (basket_select$type == "sdg") { | ||
if (is.null(temp_env$sdg_db)) { | ||
data("sdg_db", envir = temp_env) | ||
} | ||
if (!is.null(basket_select$name)) { | ||
is_in_sdq <- temp_env$sdg_db$sdg_name == basket_select$name | ||
} else { | ||
is_in_sdq <- temp_env$sdg_db$sdg_id == basket_select$id | ||
} | ||
if (keep_id) { | ||
select_id <- c(GRPID = "sdg_id") | ||
} else { | ||
select_id <- NULL | ||
} | ||
keep_cols <- c( | ||
TERMNAME = "termname", | ||
SRCVAR = "termvar", | ||
GRPNAME = "sdg_name", | ||
select_id | ||
) | ||
|
||
structure( | ||
temp_env$sdg_db[is_in_sdq, keep_cols], | ||
names = names(keep_cols) | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,22 @@ | ||
# from CDISC pilot study ---- | ||
# Datasets: ae, suppae | ||
# Description: Standard AE, SUPPAE datasets from CDISC pilot study | ||
|
||
# Load libraries ----- | ||
library(dplyr) | ||
library(metatools) | ||
library(haven) | ||
library(admiral) | ||
|
||
# Create ae, suppae ---- | ||
raw_ae <- read_xpt("https://github.com/cdisc-org/sdtm-adam-pilot-project/blob/master/updated-pilot-submission-package/900172/m5/datasets/cdiscpilot01/tabulations/sdtm/ae.xpt?raw=true") # nolint | ||
raw_suppae <- read_xpt("https://github.com/cdisc-org/sdtm-adam-pilot-project/blob/master/updated-pilot-submission-package/900172/m5/datasets/cdiscpilot01/tabulations/sdtm/suppae.xpt?raw=true") # nolint | ||
ae <- convert_blanks_to_na(raw_ae) | ||
suppae <- convert_blanks_to_na(raw_suppae) | ||
|
||
# Save dataset ---- | ||
save(ae, file = "data/ae.rda", compress = "bzip2") | ||
# Label dataset ---- | ||
attr(ae, "label") <- "Adverse Events" | ||
attr(suppae, "label") <- "Supplemental Qualifiers for AE" | ||
|
||
# Save datasets ---- | ||
usethis::use_data(ae, overwrite = TRUE) | ||
usethis::use_data(suppae, overwrite = TRUE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,16 @@ | ||
# from CDISC pilot study ---- | ||
# Dataset: cm | ||
# Description: Standard CM dataset from CDISC pilot study | ||
|
||
# Load libraries ----- | ||
library(haven) | ||
library(admiral) | ||
|
||
# Create cm ---- | ||
raw_cm <- read_xpt("https://github.com/cdisc-org/sdtm-adam-pilot-project/blob/master/updated-pilot-submission-package/900172/m5/datasets/cdiscpilot01/tabulations/sdtm/cm.xpt?raw=true") # nolint | ||
cm <- convert_blanks_to_na(raw_cm) | ||
|
||
# Label dataset ---- | ||
attr(cm, "label") <- "Concomitant Medications" | ||
|
||
# Save dataset ---- | ||
usethis::use_data(cm, overwrite = TRUE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,21 @@ | ||
# from CDISC pilot study ---- | ||
# Datasets: dm, suppdm | ||
# Description: Standard DM, SUPPDM datasets from CDISC pilot study | ||
|
||
# Load libraries ----- | ||
library(haven) | ||
library(admiral) | ||
|
||
# Create dm, suppdm ---- | ||
sdtm_path <- "https://github.com/cdisc-org/sdtm-adam-pilot-project/blob/master/updated-pilot-submission-package/900172/m5/datasets/cdiscpilot01/tabulations/sdtm/" # nolint | ||
raw_dm <- read_xpt(paste0(sdtm_path, "dm", ".xpt?raw=true")) | ||
raw_suppdm <- read_xpt(paste0(sdtm_path, "suppdm", ".xpt?raw=true")) | ||
dm <- convert_blanks_to_na(raw_dm) | ||
suppdm <- convert_blanks_to_na(raw_suppdm) | ||
|
||
# Label dataset ---- | ||
attr(dm, "label") <- "Demographics" | ||
attr(suppdm, "label") <- "Supplemental Qualifiers for DM" | ||
|
||
# Save datasets ---- | ||
usethis::use_data(dm, overwrite = TRUE) | ||
usethis::use_data(suppdm, overwrite = TRUE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,16 @@ | ||
# from CDISC pilot study ---- | ||
# Dataset: ex | ||
# Description: Standard EX dataset from CDISC pilot study | ||
|
||
# Load libraries ----- | ||
library(haven) | ||
library(admiral) | ||
|
||
# Create ex ---- | ||
raw_ex <- read_xpt("https://github.com/cdisc-org/sdtm-adam-pilot-project/blob/master/updated-pilot-submission-package/900172/m5/datasets/cdiscpilot01/tabulations/sdtm/ex.xpt?raw=true") # nolint | ||
ex <- convert_blanks_to_na(raw_ex) | ||
|
||
# Label dataset ---- | ||
attr(ex, "label") <- "Exposure" | ||
|
||
# Save dataset ---- | ||
usethis::use_data(ex, overwrite = TRUE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.