Learn R Programming

LearningRlab (version 2.4)

pearson_: Pearson Correlation Calculus Function

Description

This function calculates the pearson correlation of two vectors of numbers.

Usage

pearson_(x,y)

Value

Numeric, the pearson correlation of two vectors of numbers.

Arguments

x

Should be a vector

y

Should be a vector

Author

Jose Manuel Gomez Caceres, josemanuel.gomezc@edu.uah.es
Juan Jose Cuadrado, jjcg@uah.es
Universidad de Alcala de Henares

Details

To calculate the pearson correlation, the user should give two vectors of numbers. The result is the covariance of the two vectors of numbers divided by the product of their standard deviations. The pearson correlation formule is the following:

Examples

Run this code

    #data creation
    data = c(1,4,3,3,2,5,7,12,1,2,3,12)
    data2 = c(1,2,4,4,6,5,11,2,10,5,6,1)
    pearson_(data, data2)
  

Run the code above in your browser using DataLab