# ============================================================
# Your First Plot in R
# R Foundations — Rverse Analytics
# https://rverseanalytics.com/learn/first-plot
# ============================================================

# Your First Plot in R - base graphics
# 1. A histogram: the shape of one variable
hist(mtcars$mpg, col = "#2f6fed", main = "Fuel efficiency", xlab = "Miles per gallon")
# 2. A scatter plot: two variables
plot(mtcars$wt, mtcars$mpg, pch = 19, col = "#17a2b8", xlab = "Weight (1000 lbs)", ylab = "Miles per gallon")
# 3. Add a regression trend line
plot(mtcars$wt, mtcars$mpg, pch = 19, col = "#17a2b8", xlab = "Weight", ylab = "MPG")
abline(lm(mpg ~ wt, data = mtcars), col = "#b02a37", lwd = 2)
# 4. A boxplot by group
boxplot(mpg ~ cyl, data = mtcars, col = "#2f6fed33", border = "#1b2a4a", xlab = "Cylinders", ylab = "MPG")
