Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
removed supp dataset args
  • Loading branch information
arjoon-r committed Jul 31, 2024
1 parent 3d4715a commit f429c66
Showing 1 changed file with 7 additions and 40 deletions.
47 changes: 7 additions & 40 deletions R/derive_vars_merged_vaccine.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,15 @@
#' The variables to be added to the output dataset will be based on input variables
#' passed on `ex_vars` argument.
#'
#' @param dataset Input dataset
#' @param dataset Input dataset which should have been combined with the supplementary(if exists).
#'
#' The variables specified by the `by_vars` argument inside the
#' `derive_vars_merged`are expected.
#'
#' @param dataset_ex EX dataset to merge with the input dataset.
#' @param dataset_ex `ex` dataset(combined with `suppex`) to merge with the input dataset.
#'
#' The variables specified by the `ex_vars` argument are expected.
#'
#' @param dataset_supp Supplementary input dataset
#'
#' By default `dataset_supp` will be `NULL`, user has to provide
#' supplementary dataset to merge it back with original input dataset
#' if they have supplementary dataset in their case.
#'
#' @param dataset_suppex Supplementary EX dataset
#'
#' By default `dataset_suppex` will be `NULL`, user has to provide
#' supplementary dataset to merge it back with original `EX` dataset
#' if they have supplementary dataset in their case.
#'
#' @param by_vars_sys Grouping variables for systemic events.
#'
#' @param by_vars_adms Grouping variables for administration site events.
Expand All @@ -45,8 +33,7 @@
#' Only the variables passed to the `ex_vars` will be added in the output dataset
#'
#' If the input dataset has multiple vaccination for a subject at same visit
#' then this function will not merge ex dataset and will return only the input
#' dataset merged with its supplementary dataset.
#' then this function will not merge ex dataset and will return the `dataset`.
#'
#' @author Vikram S
#'
Expand All @@ -66,8 +53,6 @@
#' derive_vars_merged_vaccine(
#' dataset = face_vaccine,
#' dataset_ex = ex_vaccine,
#' dataset_supp = NULL,
#' dataset_suppex = NULL,
#' by_vars_sys = exprs(USUBJID, FATPTREF = EXLNKGRP),
#' by_vars_adms = exprs(USUBJID, FATPTREF = EXLNKGRP, FALOC = EXLOC, FALAT = EXLAT),
#' ex_vars = exprs(EXTRT, EXDOSE, EXDOSU, EXSTDTC, EXENDTC)
Expand All @@ -78,38 +63,21 @@
#' derive_vars_merged_vaccine(
#' dataset = face_vaccine,
#' dataset_ex = ex_vaccine,
#' dataset_supp = suppface_vaccine,
#' dataset_suppex = suppex_vaccine,
#' by_vars_sys = exprs(USUBJID, FATPTREF = EXLNKGRP),
#' by_vars_adms = exprs(USUBJID, FATPTREF = EXLNKGRP, FALOC = EXLOC, FALAT = EXLAT),
#' ex_vars = exprs(EXTRT, EXDOSE, EXDOSU, EXSTDTC, EXENDTC)
#' ) %>%
#' filter(CLTYP == "DAIRY") %>%
#' select(USUBJID, FATPTREF, CLTYP, EXTRT, EXDOSE, EXDOSU, EXSTDTC, EXENDTC)
#' )
#'
derive_vars_merged_vaccine <- function(dataset,
dataset_ex,
by_vars_sys,
by_vars_adms,
dataset_supp = NULL,
dataset_suppex = NULL,
ex_vars) {
assert_data_frame(dataset)
assert_vars(by_vars_sys)
assert_vars(by_vars_adms)
assert_vars(ex_vars)
assert_data_frame(dataset_supp, optional = TRUE)
assert_data_frame(dataset_ex)
assert_data_frame(dataset_suppex, optional = TRUE)

# combine face and suppface dataset
if (!is.null(dataset_supp)) {
dataset <- combine_supp(dataset, dataset_supp)
}

# combine face and suppex dataset
if (!is.null(dataset_suppex)) {
dataset_ex <- combine_supp(dataset_ex, dataset_suppex)
}

if ("VISIT" %in% names(dataset_ex)) {
ex_distinct <- dataset_ex %>% distinct(USUBJID, VISIT, .keep_all = TRUE)
Expand All @@ -119,8 +87,7 @@ derive_vars_merged_vaccine <- function(dataset,

if (nrow(dataset_ex) != nrow(ex_distinct)) {
warning("Subjects have multiple vaccinations at same visit")

dataset <- dataset
return(dataset)
} else {
# Filter records for ADMINISTRATION SITE events and merge it with EX dataset
dataset_adminstration <- dataset %>%
Expand All @@ -145,6 +112,6 @@ derive_vars_merged_vaccine <- function(dataset,
)

# bind face1 and face2 datasets
bind_rows(face1, face2)
return(bind_rows(face1, face2))
}
}

0 comments on commit f429c66

Please sign in to comment.