signrank: Wilcoxon Signed-rank Test

View source: R/nonparametric.R

signrankR Documentation

Wilcoxon Signed-rank Test

Description

Performs a one-sample or paired Wilcoxon signed-rank test. With two variables, complete pairs are analyzed and the tested difference is x - y.

Usage

signrank(
  x,
  y = NULL,
  data = NULL,
  mu = 0,
  alternative = c("two.sided", "less", "greater"),
  exact = NULL,
  correct = TRUE,
  conf.int = TRUE,
  level = 0.95,
  digits = 3,
  p_digits = 3,
  show = TRUE,
  console = FALSE
)

Arguments

x

Numeric variable or first paired measurement.

y

Optional second paired measurement.

data

Data frame. If NULL, active R4VN data is used.

mu

Null median or null median paired difference.

alternative

Alternative hypothesis.

exact

Use an exact p-value when possible. NULL lets R decide.

correct

Apply continuity correction for the normal approximation.

conf.int

Report a pseudomedian or paired location-shift estimate and confidence interval when available.

level

Confidence level.

digits, p_digits

Decimal places for estimates and p-values.

show

Logical; open the formatted result in the Viewer. Default TRUE.

console

Logical; also print the traditional result in the Console. Default FALSE.

Value

Invisibly returns an object of class r4vn_stat.

Examples

d <- data.frame(
  before = c(18, 20, 15, 22, 17, 19, 24, 16),
  after  = c(15, 18, 14, 19, 16, 17, 20, 15)
)
signrank(before, data = d, mu = 18)
signrank(before, after, data = d)
signrank(before, after, data = d, alternative = "greater")

# Extended usage examples

d <- data.frame(
  before = c(18, 20, 15, 22, 17, 19, 24, 16),
  after = c(15, 18, 14, 19, 16, 17, 20, 15)
)

# One-sample signed-rank test against a specified median
signrank(before, data = d, mu = 18)

# Paired signed-rank test; the analyzed difference is before - after
signrank(before, after, data = d)
signrank(before, after, data = d, alternative = "greater")

# Approximation and confidence-interval controls
signrank(before, after, data = d, exact = FALSE, correct = FALSE)
signrank(before, after, data = d, conf.int = FALSE)

usedf(d)
signrank(before, after)


R4VN documentation built on Sept. 30, 2026, 5:13 p.m.