ard_wilcoxtest {cardx}R Documentation

ARD Wilcoxon Rank-Sum Test

Description

Analysis results data for paired and non-paired Wilcoxon Rank-Sum tests.

Usage

ard_wilcoxtest(data, by, variable, ...)

ard_paired_wilcoxtest(data, by, variable, id, ...)

Arguments

data

(data.frame)
a data frame. See below for details.

by

(tidy-select)
column name to compare by.

variable

(tidy-select)
column name to be compared.

...

arguments passed to wilcox.test(...)

id

(tidy-select)
column name of the subject or participant ID.

Details

For the ard_wilcoxtest() function, the data is expected to be one row per subject. The data is passed as wilcox.test(data[[variable]] ~ data[[by]], paired = FALSE, ...).

For the ard_paired_wilcoxtest() function, the data is expected to be one row per subject per by level. Before the test is calculated, the data are reshaped to a wide format to be one row per subject. The data are then passed as ⁠wilcox.test(x = data_wide[[<by level 1>]], y = data_wide[[<by level 2>]], paired = TRUE, ...)⁠.

Value

ARD data frame

Examples

cards::ADSL |>
  dplyr::filter(ARM %in% c("Placebo", "Xanomeline High Dose")) |>
  ard_wilcoxtest(by = "ARM", variable = "AGE")

# constructing a paired data set,
# where patients receive both treatments
cards::ADSL[c("ARM", "AGE")] |>
  dplyr::filter(ARM %in% c("Placebo", "Xanomeline High Dose")) |>
  dplyr::mutate(.by = ARM, USUBJID = dplyr::row_number()) |>
  dplyr::arrange(USUBJID, ARM) |>
  ard_paired_wilcoxtest(by = ARM, variable = AGE, id = USUBJID)

[Package cardx version 0.1.0 Index]