Learn R Programming

UAHDataScienceSF (version 1.0.0)

pearson: Pearson Correlation Function

Description

This function calculates the Pearson correlation coefficient between two vectors of numbers.

Usage

pearson(x = NULL, y = NULL, learn = FALSE, interactive = FALSE)

Value

The Pearson correlation coefficient between the two vectors (for non-interactive mode)

Arguments

x

Optional first numeric vector (not needed for interactive mode)

y

Optional second numeric vector (not needed for interactive mode)

learn

Logical, if TRUE shows step-by-step explanation

interactive

Logical, if TRUE enables interactive practice mode

Examples

Run this code
data <- c(10,4,5,7,3,4,1)
data2 <- c(1,8,3,4,4,5,7)

# Simple calculation
pearson(data, data2)

# Learning mode
pearson(data, data2, learn = TRUE)

# Interactive mode
if(interactive()){
pearson(interactive = TRUE)
}

Run the code above in your browser using DataLab