---
title: "Karnataka Agricultural Market Data Dashboard"
output:
flexdashboard::flex_dashboard:
orientation: rows
vertical_layout: scroll
theme: spacelab
social: menu
source_code: embed
---
```{r setup, include=FALSE}
library(tidyverse)
library(ggplot2)
library(flexdashboard)
library(lattice)
library(MASS)
library(scales)
library(DT)
library(knitr)
data <- read_csv("C:/Users/USER/Documents/BDA/EDA_assignment/AGRI_MARKET_DATA_KARNATAKA.csv")
```
## Dataset Description {.tabset}
### View of Dataset
```{r}
# Convert data to a data frame or matrix if necessary
data_matrix <- as.matrix(data)
datatable(data,extensions= 'Buttons',options=list(dom = 'Bfrtip',Buttons =c('copy','csv','print','pdf')))
```
### Dataset Structure
```{r}
str(data)
```
### Summary of Data
```{r}
summary(data)
```
```{r}
# Filter data for coconut and group by month to get the total arrival
coconut_arrival <- data %>%
filter(Commodity == "Coconut") %>%
group_by(Month) %>%
summarise(Total_Arrival = sum(Arrival))
```
## Univariate Analysis {.tabset}
### Analysis of Coconut by month
```{r}
# Plot coconut arrival by month (histogram)
ggplot(coconut_arrival, aes(x = Month, y = Total_Arrival)) +
geom_col(fill = "lightblue") +
ggtitle("Coconut Arrival by Month") +
xlab("Month") + ylab("Total Arrival") +
scale_y_continuous(labels = comma) # Use comma formatting
```
```{r}
cow_arrival <- data %>%
filter(Commodity == "Cow") %>%
group_by(Month) %>%
summarise(Total_Arrival = sum(Arrival))
```
### Analysis of Cow by month
```{r}
# Plot coconut arrival by moont (histogram)
ggplot(cow_arrival, aes(x = Month, y = Total_Arrival)) +
geom_col(fill = "lightblue") +
ggtitle("Cow Arrival by Month") +
xlab("Month") + ylab("Total Arrival") +
scale_y_continuous(labels = comma) # Use comma formatting
```
```{r}
goat_arrival <- data %>%
filter(Commodity == "Goat") %>%
group_by(Month) %>%
summarise(Total_Arrival = sum(Arrival))
```
### Analysis of Goat by month
```{r}
# Plot Goat arrival by moont (histogram)
ggplot(goat_arrival, aes(x = Month, y = Total_Arrival)) +
geom_col(fill = "lightblue") +
ggtitle("Goat Arrival by Month") +
xlab("Month") + ylab("Total Arrival") +
scale_y_continuous(labels = comma) # Use comma formatting
```
```{r}
# Filter data for specific commodities
selected_commodities <- c("Ox", "Cow", "Goat")
filtered_data <- data %>%
filter(Commodity %in% selected_commodities)
```
## Bivariate Analysis(Boxplot) {.tabset}
### Commodities arrival across months
```{r}
# Boxplot of selected commodities' arrivals across months
ggplot(filtered_data, aes(x = Commodity, y = Arrival, fill = Commodity)) +
geom_boxplot() +
ggtitle("Commodity Arrivals (Ox, Cow, Goat)") +
xlab("Commodity") + ylab("Arrival") +
theme_minimal() +
theme(axis.text.x = element_text(angle = 45, hjust = 1)) # Rotate x-axis labels for clarity
```
```{r}
# Filter data for specific commodities
specific_commodities <- c("Cabbage", "Carrot", "Sunflower")
filtered_data2 <- data %>%
filter(Commodity %in% specific_commodities)
```
### Total_Arrivals (Cabbage, Carrot, sunflower)
```{r}
# Boxplot of selected commodities' arrivals across months
ggplot(filtered_data2, aes(x = Commodity, y = Arrival, fill = Commodity)) +
geom_boxplot() +
ggtitle("Commodity Arrivals (Ox, Cow, Goat)") +
xlab("Commodity") + ylab("Arrival") +
theme_minimal() +
theme(axis.text.x = element_text(angle = 100, hjust = 1)) # Rotate x-axis labels for clarity
```
```{r}
grapes_data <- data %>%
filter(Commodity == "Grapes")
```
## Scatterplot {.tabset}
### Grapes Data By month
```{r}
# Scatterplot of Coconut arrivals by month
ggplot(grapes_data, aes(x = Month, y = Arrival)) +
geom_point(color = "steelblue", size = 3) +
ggtitle("Grapes Arrivals by Month") +
xlab("Month") + ylab("Arrival") +
theme_minimal() +
theme(axis.text.x = element_text(angle = 45, hjust = 1)) +
scale_y_continuous(labels = comma)# Rotate x-axis labels for readability
```