diff --git a/DESCRIPTION b/DESCRIPTION index ae59ed9..fb97d05 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -24,7 +24,7 @@ Description: Provide a library of methods that can be used to calculate differen License: MIT + file LICENSE Encoding: UTF-8 Roxygen: list(markdown = TRUE) -RoxygenNote: 7.2.3 +RoxygenNote: 7.3.1 Suggests: covr, pkgdown, @@ -41,6 +41,10 @@ Imports: stats, data.table (>= 1.14.2), magrittr, - checkmate + checkmate, + cli, + usethis +Remotes: + hta-pharma/chef Config/testthat/edition: 3 VignetteBuilder: knitr diff --git a/R/across_strata_across_trt.R b/R/across_strata_across_trt.R index 692437d..88e8fc9 100644 --- a/R/across_strata_across_trt.R +++ b/R/across_strata_across_trt.R @@ -10,6 +10,7 @@ #' @param strata_var character. Variable in the analysis data to stratify by specific for this call. #' @param odds_ratio numeric. Odds Ration (default = NA). #' @param correct logical. If TRUE Tarones correction is returned (default = FALSE). +#' @param ... Optional parameters. #' #' @return A data.table containing the statistics for p-value interaction tests. #' @export diff --git a/R/by_strata_across_trt.R b/R/by_strata_across_trt.R index a2cec56..596476f 100644 --- a/R/by_strata_across_trt.R +++ b/R/by_strata_across_trt.R @@ -14,6 +14,7 @@ #' @param treatment_var character. The name of the treatment variable in the data. #' @param treatment_refval character. The reference value of the treatment variable in the data. #' @param subjectid_var character. Name of the subject identifier variable in the data (default is "USUBJID"). +#' @param ... Optional parameters. #' #' @return A data.table containing Relative Risk statistics. #' @export @@ -70,6 +71,7 @@ RR <- function(dat, #' @param treatment_var character. The name of the treatment variable in the data. #' @param treatment_refval character. The reference value of the treatment variable in the data. #' @param subjectid_var character. Name of the subject identifier variable in the data (default is "USUBJID"). +#' @param ... Optional parameters. #' #' @return A data.table containing Odds Ratio statistics. #' @export @@ -127,6 +129,8 @@ OR <- function(dat, #' @param treatment_var character. The name of the treatment variable in the data. #' @param treatment_refval character. The reference value of the treatment variable in the data. #' @param subjectid_var character. Name of the subject identifier variable in the data (default is "USUBJID"). +#' @param as_pct Boolean. +#' @param ... Optional parameters. #' #' @return A data.table containing Risk Difference statistics. #' @export @@ -183,13 +187,13 @@ RD <- function(dat, #' analyzed. See the "Endpoint Events" vignette in {ramnog} #' for more information. #' @param safe_mode Boolean determing if the function should fail when given -#' input that cannot be calculated (`safe_mode = TRUE`), or if it should +#' input that cannot be calculated (`safe_mode = TRUE`), or if it should silently return a `NA` value (default). #' @param treatment_var character. The name of the treatment variable in the data. #' @param treatment_refval character. The reference value of the treatment variable in the data. #' @param subjectid_var character. Name of the subject identifier variable in the data (default is "USUBJID"). #' @param threshold_lower numeric. Lower threshold limit for selecting Fischer vs. Barnard. #' @param threshold_upper numeric. Upper threshold limit for selecting Fischer vs. Barnard. -#' silently return a `NA` value (default). +#' @param ... Optional parameters. #' @return A data.table containing p-value statistics. #' @export p_val <- diff --git a/R/by_strata_by_trt.R b/R/by_strata_by_trt.R index 154e4a8..b2201a6 100644 --- a/R/by_strata_by_trt.R +++ b/R/by_strata_by_trt.R @@ -301,7 +301,7 @@ total_missing_counts <- function(dat_cell, stratify_by) { #' analyzed. See the "Endpoint Events" vignette in {ramnog} #' for more information. #' @param subjectid_var character. Name of the subject identifier variable in the data (default is "USUBJID"). -#' @param treatment_var character. Name of the treatment variable in the data. +#' @param var character. Name of the variable in the analysis data that is subject to the statistics. #' @param ... Optional parameters. #' #' @return A data.table containing the percentage of subjects with events by treatment. @@ -344,6 +344,8 @@ mean_value <- function(dat, #' for more information. #' @param subjectid_var character. Name of the subject identifier variable in the data (default is "USUBJID"). #' @param treatment_var character. Name of the treatment variable in the data. +#' @param treatment_value character. Value of the treatment variable in the data. +#' @param ... Optional parameters. #' #' @return A data.table containing the percentage of subjects with events by treatment. #' @export diff --git a/R/globals.R b/R/globals.R index d93da83..4fff8da 100644 --- a/R/globals.R +++ b/R/globals.R @@ -12,6 +12,6 @@ utils::globalVariables( "stat_var", "value", "N_sub", - "N_no_event", + "N_no_event" ) ) diff --git a/R/two_by_two_x.R b/R/two_by_two_x.R index f2816e5..353240c 100644 --- a/R/two_by_two_x.R +++ b/R/two_by_two_x.R @@ -12,14 +12,18 @@ #' #' Only observations that have a Treatment value recorded are returned. -#'@param dat The ADaM table produced by baker -#'@param treatment_var character. The name of the treatment variable -#'@param treatment_refval character. The reference value of the treatment -#'@param keepflg_var character. The name of the variable in the enriched ADaM -#' data.table that contains the flag indicating whether each record fulfilled -#' the criteria for being considered an event for the specific endpoint -#' -#' @return A matrix +#' @param dat data.table. The analysis data set. +#' @param event_index vector of integers that index the rows in `dat` that match +#' the definition of an 'event'. Matching is done via the `INDEX_` column in +#' `dat`. +#' @param cell_index A vector of integers referencing the rows of `dat` (as +#' specified by the `INDEX_` column in `dat`) that match the population to be +#' analyzed. See the "Endpoint Events" vignette in {ramnog} +#' for more information. +#' @param treatment_var character. The name of the treatment variable in `dat`. +#' @param treatment_refval character. The reference value of the treatment variable in `dat`. +#' @param subjectid_var character. Name of the subject identifier variable in `dat` (default is "USUBJID"). +#'@return A matrix #' @export #' mk_two_by_two <- @@ -120,16 +124,12 @@ ensure_complete_two_by_two <- function(two_by_two_long, treatment_var) { #' generalized #' #' -#' @param dat data.table. An enriched ADaM table -#' @param treatment_refval character. The treatment reference group -#' @param treatment_var character. The name of the column containing the -#' treatment value -#' @param subjectid_var character. The name of the column in the enriched ADaM -#' dataset containing the unique subject id (default = `USUBJID`). -#' @param event_index -#' @param cell_index -#' @param strata_var -#' +#' @param dat data.table. The analysis data set. +#' @param event_index vector of integers that index the rows in `dat` that match the definition of an 'event'. Matching is done via the `INDEX_` column in `dat`. +#' @param strata_var character. Variable in `dat` to stratify by specific for this call. +#' @param treatment_var character. The name of the treatment variable in `dat`. +#' @param treatment_refval character. The reference value of the treatment variable in `dat`. +#' @param subjectid_var character. Name of the subject identifier variable in `dat` (default is "USUBJID"). #' @return A two-by-two-by-k array where k represents the number of subgroups #' (strata). #' @export diff --git a/R/use_chefStats.R b/R/use_chefStats.R index 8d8ff3c..f7abfc8 100644 --- a/R/use_chefStats.R +++ b/R/use_chefStats.R @@ -10,7 +10,6 @@ #' @return Nothing, run for side-effect (writes file to disk) #' @export #' -#' @examples use_chefStats <- function(fn_name, fn_type = c( diff --git a/man/OR.Rd b/man/OR.Rd index 52eeb48..584496e 100644 --- a/man/OR.Rd +++ b/man/OR.Rd @@ -31,6 +31,8 @@ for more information.} \item{treatment_refval}{character. The reference value of the treatment variable in the data.} \item{subjectid_var}{character. Name of the subject identifier variable in the data (default is "USUBJID").} + +\item{...}{Optional parameters.} } \value{ A data.table containing Odds Ratio statistics. diff --git a/man/RD.Rd b/man/RD.Rd index 057f46e..2be2fac 100644 --- a/man/RD.Rd +++ b/man/RD.Rd @@ -32,6 +32,10 @@ for more information.} \item{treatment_refval}{character. The reference value of the treatment variable in the data.} \item{subjectid_var}{character. Name of the subject identifier variable in the data (default is "USUBJID").} + +\item{as_pct}{Boolean.} + +\item{...}{Optional parameters.} } \value{ A data.table containing Risk Difference statistics. diff --git a/man/RR.Rd b/man/RR.Rd index 7cc8843..b465cca 100644 --- a/man/RR.Rd +++ b/man/RR.Rd @@ -31,6 +31,8 @@ for more information.} \item{treatment_refval}{character. The reference value of the treatment variable in the data.} \item{subjectid_var}{character. Name of the subject identifier variable in the data (default is "USUBJID").} + +\item{...}{Optional parameters.} } \value{ A data.table containing Relative Risk statistics. diff --git a/man/make_two_by_two_by_k.Rd b/man/make_two_by_two_by_k.Rd index 871ab34..00c06e0 100644 --- a/man/make_two_by_two_by_k.Rd +++ b/man/make_two_by_two_by_k.Rd @@ -15,17 +15,17 @@ make_two_by_two_by_k( ) } \arguments{ -\item{dat}{data.table. An enriched ADaM table} +\item{dat}{data.table. The analysis data set.} -\item{strata_var}{} +\item{event_index}{vector of integers that index the rows in \code{dat} that match the definition of an 'event'. Matching is done via the \code{INDEX_} column in \code{dat}.} -\item{treatment_var}{character. The name of the column containing the -treatment value} +\item{strata_var}{character. Variable in \code{dat} to stratify by specific for this call.} -\item{treatment_refval}{character. The treatment reference group} +\item{treatment_var}{character. The name of the treatment variable in \code{dat}.} -\item{subjectid_var}{character. The name of the column in the enriched ADaM -dataset containing the unique subject id (default = \code{USUBJID}).} +\item{treatment_refval}{character. The reference value of the treatment variable in \code{dat}.} + +\item{subjectid_var}{character. Name of the subject identifier variable in \code{dat} (default is "USUBJID").} } \value{ A two-by-two-by-k array where k represents the number of subgroups diff --git a/man/mean_value.Rd b/man/mean_value.Rd index 66afdbd..107190c 100644 --- a/man/mean_value.Rd +++ b/man/mean_value.Rd @@ -25,8 +25,6 @@ for more information.} \item{var}{character. Name of the variable in the analysis data that is subject to the statistics.} \item{...}{Optional parameters.} - -\item{treatment_var}{character. Name of the treatment variable in the data.} } \value{ A data.table containing the percentage of subjects with events by treatment. diff --git a/man/mk_two_by_two.Rd b/man/mk_two_by_two.Rd index e94ba4b..97fa08d 100644 --- a/man/mk_two_by_two.Rd +++ b/man/mk_two_by_two.Rd @@ -14,15 +14,22 @@ mk_two_by_two( ) } \arguments{ -\item{dat}{The ADaM table produced by baker} +\item{dat}{data.table. The analysis data set.} -\item{treatment_var}{character. The name of the treatment variable} +\item{event_index}{vector of integers that index the rows in \code{dat} that match +the definition of an 'event'. Matching is done via the \code{INDEX_} column in +\code{dat}.} -\item{treatment_refval}{character. The reference value of the treatment} +\item{cell_index}{A vector of integers referencing the rows of \code{dat} (as +specified by the \code{INDEX_} column in \code{dat}) that match the population to be +analyzed. See the "Endpoint Events" vignette in {ramnog} +for more information.} -\item{keepflg_var}{character. The name of the variable in the enriched ADaM -data.table that contains the flag indicating whether each record fulfilled -the criteria for being considered an event for the specific endpoint} +\item{treatment_var}{character. The name of the treatment variable in \code{dat}.} + +\item{treatment_refval}{character. The reference value of the treatment variable in \code{dat}.} + +\item{subjectid_var}{character. Name of the subject identifier variable in \code{dat} (default is "USUBJID").} } \value{ A matrix diff --git a/man/p_subj_event_by_trt.Rd b/man/p_subj_event_by_trt.Rd index d13cc6c..f06b52d 100644 --- a/man/p_subj_event_by_trt.Rd +++ b/man/p_subj_event_by_trt.Rd @@ -29,6 +29,10 @@ for more information.} \item{subjectid_var}{character. Name of the subject identifier variable in the data (default is "USUBJID").} \item{treatment_var}{character. Name of the treatment variable in the data.} + +\item{treatment_value}{character. Value of the treatment variable in the data.} + +\item{...}{Optional parameters.} } \value{ A data.table containing the percentage of subjects with events by treatment. diff --git a/man/p_val.Rd b/man/p_val.Rd index d49184b..b40973b 100644 --- a/man/p_val.Rd +++ b/man/p_val.Rd @@ -36,12 +36,13 @@ for more information.} \item{subjectid_var}{character. Name of the subject identifier variable in the data (default is "USUBJID").} \item{safe_mode}{Boolean determing if the function should fail when given -input that cannot be calculated (\code{safe_mode = TRUE}), or if it should} +input that cannot be calculated (\code{safe_mode = TRUE}), or if it should silently return a \code{NA} value (default).} \item{threshold_lower}{numeric. Lower threshold limit for selecting Fischer vs. Barnard.} -\item{threshold_upper}{numeric. Upper threshold limit for selecting Fischer vs. Barnard. -silently return a \code{NA} value (default).} +\item{threshold_upper}{numeric. Upper threshold limit for selecting Fischer vs. Barnard.} + +\item{...}{Optional parameters.} } \value{ A data.table containing p-value statistics. diff --git a/man/p_val_interaction.Rd b/man/p_val_interaction.Rd index 1e14021..bd7fd72 100644 --- a/man/p_val_interaction.Rd +++ b/man/p_val_interaction.Rd @@ -34,6 +34,8 @@ the definition of an 'event'. Matching is done via the \code{INDEX_} column in \item{odds_ratio}{numeric. Odds Ration (default = NA).} \item{correct}{logical. If TRUE Tarones correction is returned (default = FALSE).} + +\item{...}{Optional parameters.} } \value{ A data.table containing the statistics for p-value interaction tests. diff --git a/tests/testthat/_snaps/demographics.md b/tests/testthat/_snaps/demographics.md index 67a05ee..9d0b477 100644 --- a/tests/testthat/_snaps/demographics.md +++ b/tests/testthat/_snaps/demographics.md @@ -4,6 +4,7 @@ actual_total Output label qualifiers value description + 1: n_non_missing AGEGR1 85 Demographics 2: n_missing AGEGR1 1 Demographics 3: n_non_missing SEX 82 Demographics @@ -15,5 +16,6 @@ actual_f Output label description qualifiers value + 1: n_non_missing Demographics 52