library(readxl)
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.1.4 ✔ readr 2.1.5
## ✔ forcats 1.0.0 ✔ stringr 1.5.1
## ✔ ggplot2 3.5.1 ✔ tibble 3.2.1
## ✔ lubridate 1.9.3 ✔ tidyr 1.3.1
## ✔ purrr 1.0.2
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
Energy<-read_excel("Energy.xlsx")
###1: SUMMARY OF TWO VARIABLES THAT I WOULD LIKE TO EXPLORE AND SEE IF THERE IS A CORRELATION BETWEEN THE TWO
summary(Energy$`Total people in household / Número total...`)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.000 1.000 2.000 2.341 3.000 13.000
summary(Energy$`Usage Consumption`)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.0 0.0 112.0 610.1 1039.5 10902.0
###2: HISTROGRAM FOR BOTH VARIABLES
ggplot(Energy, aes(x=`Total people in household / Número total...`)) + geom_histogram()
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
ggplot(Energy, aes(x=`Usage Consumption`)) + geom_histogram()
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
###3: PLOT THAT COMPARES BOTH VARIABLES
ggplot(Energy,aes(x=`Total people in household / Número total...`,y=`Usage Consumption`)) + geom_point()
###4: CORRELATION
cor(Energy$`Usage Consumption`, Energy$`Total people in household / Número total...`)
## [1] 0.1437128
###THERE IS A WEAK POSITIVE CORRELATION BETWEEN TOTAL PEOPLE IN HOUSEHOLD AND USAGE CONSUMPTION