---
title: "Exploratary data analysis for Diamonds data set"
output:
flexdashboard::flex_dashboard:
orientation: rows
vertical_layout: scroll
theme: journal
social: menu
source_code: embed
---
```{r setup, include=FALSE}
library(flexdashboard)
library(MASS)
library(lattice)
library(DT)
library(ggplot2)
attach(diamonds)
```
## Dataset Description {.tabset}
### View of dataset
```{r}
datatable(quine, extensions = 'Buttons' ,options = list(dom='Bfrtip',Buttons=c('copy','print','PDF','csv')))
```
## Dataset Description {.tabset}
### dataset Structure
```{r}
str(diamonds)
```
### Summary
```{r}
summary(diamonds)
```
## univariate Analysis {.tabset}
### Histogram of carat
```{r}
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")
```
### Histogram for price
```{r}
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))
```
### cut Quality
```{r}
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
```{r}
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
```{r}
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
```{r}
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
```{r}
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
```{r}
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
```{r}
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
```{r}
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)")
```