2024-10-21

Slide with code

library(ggplot2)
library(plotly)
library(dplyr)
data(airquality)
data(cars)
ggplotter <- ggplot(airquality, aes(x = Temp, y = Ozone)) + geom_point() + 
  geom_smooth(method = "lm") + 
  coord_cartesian(ylim = c(0,100))
ggplotter2 <- ggplot(cars, aes(x = speed, y = dist)) + geom_point() + 
  geom_smooth(method = "lm") + 
  coord_cartesian(ylim = c(0,100))
airquality_na <- na.omit(airquality)
line <- lm(Ozone ~ Temp, data = airquality_na)
line2 <- lm(dist ~ speed, data = cars)
x = airquality_na$Temp; y = airquality_na$Ozone
plotter = plot_ly(data = airquality_na,x= ~Temp,y = ~Ozone, type = "scatter"
,mode = "markers", width = 400, height = 400,name = "Data") %>%
  add_lines(x = x, y = fitted(line), name = "Regression") 

Slide with ggplot

Second slide with ggplot

Slide with Plotly

Slide written in latex

This is the linear regression equation for the airquality lines. The y value for this represents the Ozone value. The first decimal value represent the value of “Ozone” when the temp value is at 0. Finally, the second decimal value is the slope or ozone increase per one temperature value increase. \[ \hat{y} = -147.646 + 2.439 \cdot \]

Second Slide written in latex

This is the linear regression equation for the cars line. The y value for this equation represents the distance for cars traveling. The first decimal value represents the Distance value when the speed is zero. The second decimal value is the distance increase for each single speed increase. \[ \hat{y} = -17.579 + 3.932 \cdot \]

Final Slide

I used documentation from:
plot_ly,
slidesn
and doc2latex to understand how to write math equations in this format.