install.packages("tidyverse", repos="http://cran.us.r-project.org")
## Installing package into 'C:/Users/anjes/AppData/Local/R/win-library/4.3'
## (as 'lib' is unspecified)
## package 'tidyverse' successfully unpacked and MD5 sums checked
## 
## The downloaded binary packages are in
##  C:\Users\anjes\AppData\Local\Temp\RtmpcPFlqe\downloaded_packages
install.packages("conflicted", repos="http://cran.us.r-project.org")
## Installing package into 'C:/Users/anjes/AppData/Local/R/win-library/4.3'
## (as 'lib' is unspecified)
## package 'conflicted' successfully unpacked and MD5 sums checked
## 
## The downloaded binary packages are in
##  C:\Users\anjes\AppData\Local\Temp\RtmpcPFlqe\downloaded_packages
library(tidyverse)
## Warning: package 'tidyverse' was built under R version 4.3.3
## Warning: package 'ggplot2' was built under R version 4.3.3
## Warning: package 'readr' was built under R version 4.3.3
## Warning: package 'purrr' was built under R version 4.3.3
## ── 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
library(conflicted)
## Warning: package 'conflicted' was built under R version 4.3.3
data(women)
head(women)
##   height weight
## 1     58    115
## 2     59    117
## 3     60    120
## 4     61    123
## 5     62    126
## 6     63    129
dim(women)
## [1] 15  2
ggplot(aes(x=height, y= weight), data = women) +
  geom_point(size=3, alpha=.5)+
    geom_smooth(method = lm, se=F)+
      theme_bw()+
        labs(title ="Weight explained by height in women",
          x="Height (Explanatory or Independent variable)",
             y="Weight (Outcome or Dependent variable)")
## `geom_smooth()` using formula = 'y ~ x'

###############################################################################
#The basics of linear relationship


#Idea behind liner model is : Something about change in X(Explanatory or Independent variable) variable will be explained by Y(Outcome or dependent variable)

#Close relationship might exist here, for example: As women get taller they aslo get heavier in weight.
#In this data sample there is liner relationship exist as one go-up another go-up.

#How much change in weight can be explained by change in height.