---
title: "EDA for Diamond Dataset"
output:
flexdashboard::flex_dashboard:
orientation: rows
vertical_layout: scroll
theme: journal
social: menu
source_code: embed
---
```{r setup, include=FALSE}
library(flexdashboard)
library(ggplot2)
library(dplyr)
data("diamonds")
```
# Structure
## Structure of the Dataset
```{r}
str(diamonds)
```
# summary
## Summary of the Dataset
```{r}
summary(diamonds)
```
Column{.tabset}
-------------------------------------
# univariate Analysis
## Histogram of Carat
```{r}
Carat_Dist <- ggplot(diamonds, aes(x = carat)) +
geom_histogram(binwidth = 0.1, color = "black", fill = "steelblue") +
labs(title = "Histogram of Carat", x = "Carat", y = "Frequency") +
theme_minimal()
Carat_Dist
```
## Distribution of Price
```{r}
Price_Dist <- ggplot(diamonds, aes(x = price)) +
geom_histogram(binwidth = 100, color = "black", fill = "coral") +
labs(title = "Histogram of Price", x = "Price", y = "Frequency") +
theme_minimal()
Price_Dist
```
## Bar Plot of Cut
```{r}
Cut_Dist <- ggplot(diamonds, aes(x = cut)) +
geom_bar(fill = "lightblue") +
labs(title = "Bar plot of Cut", x = "Cut", y = "Frequency") +
theme_minimal()
Cut_Dist
```
```{r}
Color_Dist <- ggplot(diamonds, aes(x = color)) +
geom_bar(fill = "coral") +
labs(title = "Bar plot of Diamond Color", x = "Color", y = "Count") +
theme_minimal()
Color_Dist
```
## Bar Plot for Clarity
```{r}
Clarity_Dist <- ggplot(diamonds, aes(x = clarity)) +
geom_bar(fill = "lightgreen") +
labs(title = "Bar plot of Diamond Clarity", x = "Clarity", y = "Count") +
theme_minimal()
Clarity_Dist
```
# Bivariant Analysis {.tabset}
## Scatter plot for carat vs. price
```{r}
ggplot(diamonds, aes(x = carat, y = price)) +
geom_point(alpha = 0.5) +
theme_minimal() +
labs(title = "Carat vs. Price", x = "Carat", y = "Price")
```
```{r}
ggplot(diamonds, aes(x = cut, y = price, fill = cut)) +
geom_boxplot() +
theme_minimal() +
labs(title = "Price Distribution by Cut", x = "Cut", y = "Price")
```
# Multivariant Analysis
```{r}
ggplot(diamonds, aes(x = carat, y = price, color = cut)) +
geom_point(alpha = 0.5) +
facet_wrap(~cut) +
theme_minimal() +
labs(title = "Price vs. Carat by Cut", x = "Carat", y = "Price")
```
# Outlier Detection
```{r}
Carat_Box <- ggplot(diamonds, aes(y = carat)) +
geom_boxplot(fill = "steelblue") +
labs(title = "Boxplot of Carat", y = "Carat") +
theme_minimal()
Carat_Box
```
```{r}
Price_Box <- ggplot(diamonds, aes(y = price)) +
geom_boxplot(fill = "coral") +
labs(title = "Boxplot of Price", y = "Price") +
theme_minimal()
Price_Box
```