R Console
R Console
> library(ggplot2)
> library(dplyr)
filter, lag
>
> dataset <- read.csv("wine-quality-white-and-red.csv")
>
> print("Column Names:")
[1] "Column Names:"
> print(colnames(dataset))
[1] "type" "fixed.acidity" "volatile.acidity" "citric.acid"
[5] "residual.sugar" "chlorides" "free.sulfur.dioxide" "total.sulfur.dioxide"
[9] "density" "pH" "sulphates" "alcohol"
[13] "quality"
>
> ggplot(data = dataset, aes(x = fixed.acidity)) +
+ geom_histogram(binwidth = 0.5, fill = "blue", color = "black") +
+ ggtitle("Histogram of Fixed Acidity")
>
> ggplot(data = dataset, aes(x = type, y = volatile.acidity)) +
+ geom_boxplot(fill = "orange", color = "black") +
+ ggtitle("Boxplot of Volatile Acidity by Type")
>
> ggplot(data = dataset, aes(x = residual.sugar)) +
+ geom_histogram(binwidth = 1, fill = "green", color = "black") +
+ ggtitle("Histogram of Residual Sugar")
>
> ggplot(data = dataset, aes(x = type, y = chlorides)) +
+ geom_boxplot(fill = "purple", color = "black") +
+ ggtitle("Boxplot of Chlorides by Type")
>
> # Plot for 'pH'
> ggplot(data = dataset, aes(x = pH)) +
+ geom_histogram(binwidth = 0.1, fill = "red", color = "black") +
+ ggtitle("Histogram of pH")
>
> # Bar chart for 'type'
> ggplot(data = dataset, aes(x = type)) +
+ geom_bar(fill = "cyan", color = "black") +
+ ggtitle("Bar Chart of Wine Type")
>
> avg_alcohol <- dataset %>%
+ group_by(type) %>%
+ summarise(avg_alcohol = mean(alcohol, na.rm = TRUE))
>
> print("Average Alcohol Content by Type:")
[1] "Average Alcohol Content by Type:"
> print(avg_alcohol)
# A tibble: 2 × 2
type avg_alcohol
<chr> <dbl>
1 red 10.4
2 white 10.5
>
> row_count <- dataset %>%
+ group_by(type) %>%
+ summarise(count = n())
>
> print("Total Number of Rows by Type:")
[1] "Total Number of Rows by Type:"
> print(row_count)
# A tibble: 2 × 2
type count
<chr> <int>
1 red 1599
2 white 4898
>
>