Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update example in apply_metadata to reduce run time #284

Merged
merged 2 commits into from
Jul 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

### Enhancements
* Refactor `adpc` and `adab` following the new CDISC standard.

* Refactor `abab` parameters and visits to align with `adpc`.
* Skipping examples in `h_adqlqc` documentation.
* Changed example in `apply_metadata` to reduce example run time.

### Breaking changes
* Renamed `ADSL` argument to `adsl` in `radab`, `radae`, `radaette`, `radcm`, `raddv`, `radeg`, `radex`, `radhy`, `radlb`,
Expand Down
12 changes: 12 additions & 0 deletions R/radqlqc.R
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,10 @@ NULL
#' @keywords internal
#'
#' @examples
#' \dontrun{
#' qs <- random.cdisc.data:::get_qs_data(adsl, n_assessments = 5L, seed = 1, na_percentage = 0.1)
#' qs
#' }
get_qs_data <- function(adsl,
visit_format = "CYCLE",
n_assessments = 5L,
Expand Down Expand Up @@ -573,6 +575,7 @@ get_qs_data <- function(adsl,
#' @keywords internal
#'
#' @examples
#' \dontrun{
#' df <- dplyr::left_join(
#' adsl,
#' qs,
Expand All @@ -586,6 +589,7 @@ get_qs_data <- function(adsl,
#' ) |>
#' dplyr::mutate(ADTM = random.cdisc.data:::get_random_dates_between(TRTSDTM, TRTEDTM, AVISITN))
#' df
#' }
get_random_dates_between <- function(from, to, visit_id) {
min_date <- min(lubridate::as_datetime(from), na.rm = TRUE)
max_date <- max(lubridate::as_datetime(to), na.rm = TRUE)
Expand Down Expand Up @@ -617,8 +621,10 @@ get_random_dates_between <- function(from, to, visit_id) {
#' @keywords internal
#'
#' @examples
#' \dontrun{
#' adqlqc1 <- random.cdisc.data:::prep_adqlqc(df = qs)
#' adqlqc1
#' }
prep_adqlqc <- function(df) {
# create PARAMCD from QSTESTCD
adqlqc <- dplyr::mutate(
Expand Down Expand Up @@ -674,8 +680,10 @@ prep_adqlqc <- function(df) {
#' @keywords internal
#'
#' @examples
#' \dontrun{
#' df_scales <- random.cdisc.data:::calc_scales(df)
#' df_scales
#' }
calc_scales <- function(adqlqc1) {
# Prep scale data ---------------------------------------------------------
# parcat2 = scales or global health status
Expand Down Expand Up @@ -954,8 +962,10 @@ calc_scales <- function(adqlqc1) {
#' @keywords internal
#'
#' @examples
#' \dontrun{
#' adqlqc <- random.cdisc.data:::derv_chgcat1(dataset = adqlqc |> dplyr::select(-CHGCAT1))
#' adqlqc
#' }
derv_chgcat1 <- function(dataset) {
# derivation of CHGCAT1
check_vars <- c("PARCAT2", "CHG")
Expand Down Expand Up @@ -1118,8 +1128,10 @@ derv_chgcat1 <- function(dataset) {
#' @keywords internal
#'
#' @examples
#' \dontrun{
#' compliance_data <- random.cdisc.data:::comp_derv(adqlqc, 80, 2)
#' compliance_data
#' }
comp_derv <- function(dataset, percent, number) {
# original items data
orig_data <- filter(
Expand Down
8 changes: 3 additions & 5 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -231,15 +231,13 @@ var_relabel <- function(x, ...) {
#' @examples
#' seed <- 1
#' adsl <- radsl(seed = seed)
#' adlb <- radlb(adsl, seed = seed)
#' \dontrun{
#' adsub <- radsub(adsl, seed = seed)
#' yaml_path <- file.path(path.package("random.cdisc.data"), "inst", "metadata")
#' adsl <- random.cdisc.data:::apply_metadata(adsl, file.path(yaml_path, "ADSL.yml"), FALSE)
#' adlb <- random.cdisc.data:::apply_metadata(
#' adlb, file.path(yaml_path, "ADLB.yml"), TRUE,
#' adsub <- random.cdisc.data:::apply_metadata(
#' adsub, file.path(yaml_path, "ADSUB.yml"), TRUE,
#' file.path(yaml_path, "ADSL.yml")
#' )
#' }
apply_metadata <- function(df, filename, add_adsl = TRUE, adsl_filename = "metadata/ADSL.yml") {
checkmate::assert_data_frame(df)
checkmate::assert_string(filename)
Expand Down
8 changes: 3 additions & 5 deletions man/apply_metadata.Rd

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

12 changes: 12 additions & 0 deletions man/h_adqlqc.Rd

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

Loading