megacor: Generate a correlation table

View source: R/helper.R

megacorR Documentation

Generate a correlation table

Description

Creates a nicely formatted correlation table with significance indicators. uses lsr:correlate and adapts a function from http://www.sthda.com/english/wiki/elegant-correlation-table-using-xtable-r-package

Usage

megacor(
  x,
  y = NULL,
  corr.method = "pearson",
  p.adjust.method = "holm",
  removeTriangle = c("none", "upper", "lower"),
  result = c("none", "html", "latex")
)

Arguments

x

A matrix or dataframe containing variables to be correlated

y

Optionally, a second set of variables to be correlated with those in x

corr.method

What kind of correlations should be computed? Default is "pearson", but "spearman" and "kendall" are also supported

removeTriangle

Specifies the formatting of the output. Which section of the table to remove c("none", "upper", "lower")

result

Format for output c("none", "html", "latex")

Value

dataframe with correlations

Examples

megacor(df)
megacor(df[1:4],df[5:8],corr.method = "spearman", removeTriangle = "upper", result = "html")

vince-p/vtools documentation built on Jan. 27, 2024, 12:45 p.m.