Comparative Analysis of Red Wine and White Wine
2023-02-28
library(tidyverse)
library(readxl)
theme_set(theme_bw())
set.seed(123)
Introduction
Alcoholic drinks contain certain nutrients, which can not only supplement the calories
needed by the human body, but also supplement the nutrients needed by the human body.
The way of brewing red wine and white wine is different. White wine is the Chinese
culture, while red wine is the western culture. Red wine is made from grapes. White wine is
made of grain and tastes much stronger than red wine. We will explore the differences in
physical and chemical properties and quality ratings between red wine and white wine.
Analysis
Load the Data and add Type field ,then join the dataframes.Combine the red and white
datasets to make the analysis more efficient.
df <- read_excel("winequality.xlsx")
colnames(df) <- gsub(" ", ".", colnames(df))
white = df %>% filter(Type == "White Wine")
red = df %>% filter(Type == "Red Wine")
Univariate Plots and Analysis
Fixed Acidity
Note that for all displays of summary statistics, the red wines will appear on top and that
for all univariate and bivariate plots (except the scatter matrix)
red wine data is shown in plum purple and white wine data is shown in a light green.
ggplot(aes(x = fixed.acidity, fill = Type), data = df) +
geom_histogram(binwidth = 0.5) +
scale_x_continuous(breaks = seq(0, 16, by = 1)) +
facet_grid(Type~.) +
scale_fill_manual(guide=FALSE, values = c("hotpink4", "darkolivegreen3")) +
labs(x = "Tartaric Acid (g/L)", y = "Count")