Using the mtcars dataset in R, we will be learning about the population mean by examing the Miles per Gallon (mpg) and the Displacement (disp)
2023-03-15
library(tinytex)
Using the mtcars dataset in R, we will be learning about the population mean by examing the Miles per Gallon (mpg) and the Displacement (disp)
Population mean is calculating the mean for the entire group, every member. In this presentation the population mean will be of every car.
This will be the Population Mean for every vehicles MPG and DISP.
\[ \mu = \frac{\sum x}{N} \]
\[ \mu = \frac{\sum X}{N} = \] \[ \mu = \frac{642.9}{32} = 20.09062 \]
The green line is the pop mean:
The red line is the pop mean:
library(plotly, warn.conflicts = FALSE)
sorted_data <- mtcars[order(rownames(mtcars)),]
p <- plot_ly(sorted_data, x = ~disp, y = ~rownames(sorted_data), type = “scatter”, mode = “lines”)
p <- p %>% layout(xaxis = list(title = “Displacement”), yaxis = list(title = “Car Model”), title = “Line Graph of Displacement by Car Model”)
p