2025-10-20

R Markdown

This is an R Markdown presentation. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.

When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document.

## 
## Attaching package: 'Hmisc'
## The following objects are masked from 'package:base':
## 
##     format.pval, units
## Loading required package: MASS
## Loading required package: HistData
## 
## Attaching package: 'plotly'
## The following object is masked from 'package:MASS':
## 
##     select
## The following object is masked from 'package:Hmisc':
## 
##     subplot
## The following object is masked from 'package:ggplot2':
## 
##     last_plot
## The following object is masked from 'package:stats':
## 
##     filter
## The following object is masked from 'package:graphics':
## 
##     layout
## Do not use `library(config)` to attach the config package.
## Use `config::get()` directly.
## Attaching the config package can lead to namespace conflicts.
## 
## Attaching package: 'config'
## The following objects are masked from 'package:base':
## 
##     get, merge
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.1.4     ✔ readr     2.1.5
## ✔ forcats   1.0.1     ✔ stringr   1.5.2
## ✔ lubridate 1.9.4     ✔ tibble    3.3.0
## ✔ purrr     1.1.0     ✔ tidyr     1.3.1
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter()    masks plotly::filter(), stats::filter()
## ✖ dplyr::lag()       masks stats::lag()
## ✖ dplyr::select()    masks plotly::select(), MASS::select()
## ✖ dplyr::src()       masks Hmisc::src()
## ✖ dplyr::summarize() masks Hmisc::summarize()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors

Math Text in Latex:

Estimated Regression Line \[ \hat{y}_i = \hat{\beta}_0 + \hat{\beta}_1 x_i \] Least Squares Estimators \[ \hat{\beta}_1 = \frac{\sum_{i=1}^{n}(x_i - \bar{x})(y_i - \bar{y})} {\sum_{i=1}^{n}(x_i - \bar{x})^2} \]

\[ \hat{\beta}_0 = \bar{y} - \hat{\beta}_1 \bar{x} \]

Math Text in Latex cont.:

Residuals and SSE \[ e_i = y_i - \hat{y}_i \]

\[ SSE = \sum_{i=1}^{n} e_i^2 \]

Coefficient of Determination \[ R^2 = 1 - \frac{SSE}{SST} \quad \text{where} \quad SST = \sum_{i=1}^{n}(y_i - \bar{y})^2 \] ## GGPlot (flowers):

## 'data.frame':    100 obs. of  8 variables:
##  $ id      : int  1 2 3 4 5 6 7 8 9 10 ...
##  $ treat   : chr  "tip" "control" "control" "tip" ...
##  $ nitrogen: chr  "medium" "low" "low" "high" ...
##  $ height  : num  4.1 7.9 5.4 7.9 2.3 11.4 6.2 4.1 9.7 12.2 ...
##  $ block   : int  3 4 2 3 1 2 3 4 3 2 ...
##  $ leafarea: num  51.2 47.3 44 12.9 50.6 16.3 31.9 28.4 37.8 15.4 ...
##  $ width   : num  3.4 3.5 5.6 5.2 2.5 2.3 4.5 2.7 4.3 3 ...
##  $ length  : num  19.4 23.4 10.1 24.4 14.1 21.7 21.9 20 21.5 11.4 ...

GGPlot (iris):

## 'data.frame':    150 obs. of  5 variables:
##  $ Sepal.Length: num  5.1 4.9 4.7 4.6 5 5.4 4.6 5 4.4 4.9 ...
##  $ Sepal.Width : num  3.5 3 3.2 3.1 3.6 3.9 3.4 3.4 2.9 3.1 ...
##  $ Petal.Length: num  1.4 1.4 1.3 1.5 1.4 1.7 1.4 1.5 1.4 1.5 ...
##  $ Petal.Width : num  0.2 0.2 0.2 0.2 0.2 0.4 0.3 0.2 0.2 0.1 ...
##  $ Species     : Factor w/ 3 levels "setosa","versicolor",..: 1 1 1 1 1 1 1 1 1 1 ...
## `geom_smooth()` using formula = 'y ~ x'

Plotly (flowers):

## `geom_smooth()` using formula = 'y ~ x'

R Code Example:

model <- lm(Petal.Length ~ Sepal.Length, data = iris) summary(model)