Skip to contents

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

Value

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

Details

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

Examples

# Prepare Data
data("USArrests")

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




Developmental Psychopathology Lab