rcorr_padjust: Adjust p-value for an Hmisc::rcorr object

View source: R/rcorr_p_adjustment.R

rcorr_padjustR Documentation

Adjust p-value for an Hmisc::rcorr object

Description

Modifies the 'rcorr' p-values from the 'Hmisc::rcorr()' function. The result is an array with modified '$P' matrix. uses 'base::p.adjust'

Usage

rcorr_padjust(x, method = "BH")

Arguments

x

An 'rcorr' class object created by the function 'Hmisc::rcorr“

method

Uses "BH" by default

Details

Adjust Hmisc::rcorr p-values using 'p.adjust'

Value

An rcorr array with the following matrices:

  • correlation ('$r'). unchanged from the original

  • n ('$n'). unchanged from the original

  • P-value ('$P'). modified using the selected adjustment method

See Also

rcorr, heatmaply

Examples

require(Hmisc)
require(Hmisc)
set.seed(2020) # arguably the worse seed ever
test_rcorr <- Hmisc::rcorr(matrix(runif(100), nrow = 10))
test_rcorr

# use p.adjust methods
rcorr_padjust(test_rcorr) # BH by default
rcorr_padjust(test_rcorr, method = "bonferroni") # BH by default
rcorr_padjust(test_rcorr, method = "holm") # BH by default
# SUMMARY TABLE OF RESULTS
# one unadjusted result has a low P-value (p=0.008)
method = c("none", "BH", "fdr", "holm", "hochberg", "hommel", "bonferroni", "BY")
data.frame(p.adjust.method = method,
           p.adjust = map_dbl(method, ~rcorr_padjust(test_rcorr, method = .x)$P[4,5]),
          txtPval = htmlTable::txtPval(map_dbl(method, ~rcorr_padjust(test_rcorr, method = .x)$P[4,5])))

JMLuther/tabletools documentation built on July 1, 2024, 2:01 p.m.