addText {petersenlab}R Documentation

Add Correlation to Scatterplot.

Description

Add correlation text to scatterplot.

Usage

addText(
  x,
  y,
  xcoord = NULL,
  ycoord = NULL,
  size = 1,
  col = NULL,
  method = "pearson"
)

Arguments

x

vector of the variable for the x-axis.

y

vector of the variable for the y-axis.

xcoord

x-coordinate for the location of the text.

ycoord

y-coordinate for the location of the text.

size

size of the text font.

col

color of the text font.

method

method for calculating the association. One of:

  • "pearson" = Pearson product moment correlation coefficient

  • "spearman" = Spearman's rho

  • "kendall" = Kendall's tau

Details

Adds a correlation coefficient and associated p-value to a scatterplot.

Value

Correlation coefficient, degrees of freedom, and p-value printed on scatterplot.

See Also

Other plot: plot2WayInteraction(), ppPlot(), vwReg()

Other correlations: cor.table(), crossTimeCorrelation(), crossTimeCorrelationDF(), partialcor.table(), vwReg()

Examples

# Prepare Data
data("USArrests")

# Scatterplot
plot(USArrests$Assault, USArrests$Murder)
addText(x = USArrests$Assault, y = USArrests$Murder)

[Package petersenlab version 1.0.0 Index]