library(tidyverse)
## Warning: package 'ggplot2' was built under R version 4.5.2
## ── 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 4.0.2 ✔ tibble 3.3.0
## ✔ lubridate 1.9.4 ✔ tidyr 1.3.1
## ✔ purrr 1.1.0
## ── 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(dslabs)
## Warning: package 'dslabs' was built under R version 4.5.2
Load the Dataset
data("olive")
ggplot(olive, aes(x = oleic, y = linoleic, color = region)) +
geom_point(size = 3, alpha = 0.7) +
geom_smooth(method = "lm", se = TRUE, color = "black", linetype = 2, linewidth = 0.8) +
labs(
title = "Oleic vs Linoleic Acid Content in Olive Oils",
subtitle = "Comparing Fatty Acid Composition across Italian Regions",
x = "Oleic Acid (%)",
y = "Linoleic Acid (%)",
color = "Region",
caption = "Data Source : DS Labs : Olive Dataset"
) +
theme_bw() +
scale_color_brewer(palette = "Accent")
## `geom_smooth()` using formula = 'y ~ x'
For this visualization, I used the olive dataset from the DS Labs package, which contains measurements of the composition of fatty acid in olive oils collected from different regions in Italy. Each observation contains the % of the different type of fatty acid in each olive oil, and the region that it came from.
I created a scatter plot that shows the relationship between oleic acid percentage and linoleic acid percentage in olive oils. I added a third variable region, as each dot on the scatter plot is the region where the olive oil originated from. This scatter plot reveals a clear negative relationship between oleic and linoleic acids in olive oil. This means that as linoleic acid increases, oleic acid decreases, and vice versa. Also, there is three visible clusters, showing that the geographic origin of the olive oil influences the chemical composition of it. This scatter plot indicates that environmental factors and regional production methods may influence the balance of fatty acids in olive oils.