univariate Analysis
Histogram of Carat
ggplot(diamonds ,aes(carat)) +
geom_histogram( fill = "skyblue", color = "black") +
geom_vline(xintercept = mean(carat), color = "red", linetype = "dashed") +
geom_vline(xintercept = median(carat), color = "green", linetype = "dashed") +
labs(title = "Histogram of Carat",
x = "Carat Value",
y = "Count")
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

Histogram for price
ggplot(diamonds ,aes(price)) +
geom_histogram( fill = "skyblue", color = "black") +
geom_vline(xintercept = mean(price), color = "red", linetype = "dashed") +
geom_vline(xintercept = median(price), color = "green", linetype = "dashed") +
labs(title = "Histogram for price",
x = "Price",
y = "Frequence") +
xlim(c(0,10000))
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Removed 5222 rows containing non-finite outside the scale range
## (`stat_bin()`).
## Warning: Removed 2 rows containing missing values or values outside the scale range
## (`geom_bar()`).

cut Quality
ggplot(diamonds, aes(x = cut)) +
geom_bar(fill = "skyblue", color = "black") + # Basic barplot with color
labs(title = "Count of Diamonds by Cut Quality",
x = "Cut Quality",
y = "Count")

Color
ggplot(diamonds, aes(x = color)) +
geom_bar(fill = "skyblue", color = "black") + # Basic barplot with color
labs(title = "Count of Diamonds by COlor",
x = "Color",
y = "Count")

Clarity
ggplot(diamonds, aes(x = clarity)) +
geom_bar(fill = "skyblue", color = "black") + # Basic barplot with color
labs(title = "Count of Diamonds by clarity",
x = "clarity",
y = "Count")

Carat vs. Price colored by Cut
ggplot(diamonds, aes(x = carat, y = price, color = cut)) +
geom_point(alpha = 0.5) +
labs(title = "Carat vs. Price colored by Cut")

Price distribution across Cuts and Colors
ggplot(diamonds, aes(x = cut, y = price, fill = color)) +
geom_boxplot() +
labs(title = "Price distribution across Cuts and Colors")

Price distribution across Clarity and Colors
ggplot(diamonds,aes(x=clarity,y=price,fill=color)) +
geom_boxplot()+
labs(title = "Price distribution across Clarity and Colors")

Boxplot of Diamond Prices by Color
ggplot(diamonds, aes(x = color, y = price)) +
geom_boxplot() + # Create the boxplot
labs(title = "Boxplot of Diamond Prices by Color",
x = "Cut Quality",
y = "Price (in USD)")

Boxplot of Diamond Prices by Cut
ggplot(diamonds, aes(x = cut, y = price)) +
geom_boxplot() + # Create the boxplot
labs(title = "Boxplot of Diamond Prices by Cut",
x = "Cut Quality",
y = "Price (in USD)")
