FormatCorrelation {grandR}R Documentation

Formatting function for correlations

Description

Returns a function that takes x and y and returns a formatted output to describe the correlation of x and y

Usage

FormatCorrelation(
  method = "pearson",
  n.format = NULL,
  coeff.format = "%.2f",
  p.format = "%.2g",
  slope.format = NULL,
  rmsd.format = NULL
)

Arguments

method

how to compute correlation coefficients (can be pearson, spearman or kendall)

n.format

format string for the number of data points (see sprintf); can be NULL (don't output the number of data points)

coeff.format

format string for the correlation coefficient (see sprintf); can be NULL (don't output the correlation coefficient)

p.format

format string for the P value (see sprintf); can be NULL (don't output the P value)

slope.format

format string for the slope (see sprintf); can be NULL (don't output the slope)

rmsd.format

format string for the root mean square deviation (see sprintf); can be NULL (don't output the rmsd)

Details

Use this for the correlation parameter of PlotScatter

The slope is computed via a principal component analysis and *not* by linear regression

Value

a function

Examples


set.seed(42)
data <- data.frame(u=runif(500))  # generate some correlated data
data$x <- rnorm(500,mean=data$u)
data$y <- rnorm(500,mean=data$u)

fun <- FormatCorrelation()
fun(data$x,data$y)

fun <- FormatCorrelation(method="spearman",p.format="%.4g")
fun(data$x,data$y)


[Package grandR version 0.2.5 Index]