cor_tab: Calculate correlation coefficient and p-values

View source: R/mt_extra.R

cor_tabR Documentation

Calculate correlation coefficient and p-values

Description

Calculate correlation coefficient and p-values.

Usage

cor_tab(
  x,
  cor.method = c("pearson", "kendall", "spearman"),
  adj.method = c("holm", "hochberg", "hommel", "bonferroni", "BH", "BY", "fdr", "none"),
  ...
)

Arguments

x

a data frame or matrix for correlation analysis column-wise.

cor.method

method for correlation

adj.method

p-value correction method

...

other parameter for correlation.

Details

This file is modified from cor.table of package picante and corr.test of package psych. The original implementation is from Bill Venables, the author of R great book MASS. For details, see https://stat.ethz.ch/pipermail/r-help/2001-November/016201.html

Value

a list with contents:

  • r correlation coefficient

  • p statistics matrix, in which the lower triangular is p-values and the upper triangular is adjusted p-values

Examples

co <- cor_tab(mtcars, cor.method = "spearman", adj.method = "BH")
names(co)

## Not run: 
library(pysch)
co <- corr.test(mtcars, method="spearman",adjust="BH")
# From pysch: For symmetric matrices, p values adjusted for multiple tests
# are reported above the diagonal.

## End(Not run)

wanchanglin/mtExtra documentation built on Aug. 2, 2024, 5:47 p.m.