Learn R Programming

rankdifferencetest (version 2025.12.4)

rdt_data: Get data for the Kornbrot rank difference test.

Description

Gets data needed to compute Kornbrot rank difference results. The returned list is designed to be reused by higher-level functions.

Usage

rdt_data(x, ...)

# S3 method for numeric rdt_data(x, y, x_name, y_name, ...)

# S3 method for data.frame rdt_data(x, formula, agg_fun = "error", ...)

Value

list

Arguments

x

(numeric)
Numeric vector or data.frame of data. If numeric, differences of ranks correspond with x - y. Pairs with missing values are silently dropped.

...

Unused additional arguments.

y

(numeric)
Numeric vector of data. Differences of ranks correspond with x - y. Pairs with missing values are silently dropped.

x_name

(Scalar character)
Name of x variable.

y_name

(Scalar character)
Name of y variable.

formula

(formula)
A formula of form:

y ~ group | block

Use when data is in tall format. y is the numeric outcome, group is the binary grouping variable, and block is the subject/item-level variable indicating pairs of observations. group will be converted to a factor and the first level will be the reference value. For example, when levels(data$group) <- c("pre", "post"), the focal level is 'post', so differences are post - pre. Pairs with missing values are silently dropped. See agg_fun for handling duplicate cases of grouping/blocking combinations.

y ~ x

Use when data is in wide format. y and x must be numeric vectors. Differences of ranks correspond with data$y - data$x. Pairs with missing values are silently dropped.

agg_fun

(Scalar character or function: "error")
Used for aggregating duplicate cases of grouping/blocking combinations when data is in tall format and formula has structure y ~ group | block. "error" (default) will return an error if duplicate grouping/blocking combinations are encountered. Select one of "first", "last", "sum", "mean", "median", "min", or "max" for built in aggregation handling (each applies na.rm = TRUE). Or define your own function. For example, myfun <- function(x) {as.numeric(quantile(x, 0.75, na.rm = TRUE))}.