Correlación con el conjunto de dtos women

Objetivo. Determinar el valor de la correlación de Pearson entre las variables del conjunto de datos women

Las librerías

library(readr)
library(ggplot2)   ### install.packages(ggplot2")   # Para gráficos Amigable

Los datos

datos <- data.frame(women)
datos
##    height weight
## 1      58    115
## 2      59    117
## 3      60    120
## 4      61    123
## 5      62    126
## 6      63    129
## 7      64    132
## 8      65    135
## 9      66    139
## 10     67    142
## 11     68    146
## 12     69    150
## 13     70    154
## 14     71    159
## 15     72    164
str(datos)
## 'data.frame':    15 obs. of  2 variables:
##  $ height: num  58 59 60 61 62 63 64 65 66 67 ...
##  $ weight: num  115 117 120 123 126 129 132 135 139 142 ...
summary(datos)
##      height         weight     
##  Min.   :58.0   Min.   :115.0  
##  1st Qu.:61.5   1st Qu.:124.5  
##  Median :65.0   Median :135.0  
##  Mean   :65.0   Mean   :136.7  
##  3rd Qu.:68.5   3rd Qu.:148.0  
##  Max.   :72.0   Max.   :164.0

Visualizando datos

ggplot(data = datos, aes(x = height, y = weight)) +
         geom_point() 

#ggplot(datos, aes(x,y)) +
#    geom_point()

Correlación

r <- cor(datos$weight, datos$height, method = "pearson")

r <- round(r, 4) # 4 posiciones redondeado valor decimal

r
## [1] 0.9955

Interpretación

El valor del coeficiente de correlación del conjunto de datos women (datos) de las variables height & weigth es de Correlación positiva muy fuerte. . La correlación es una relación estadísticmente significativa