## Summary Statistics
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.1.4 ✔ readr 2.1.5
## ✔ forcats 1.0.0 ✔ stringr 1.5.1
## ✔ ggplot2 3.5.1 ✔ tibble 3.2.1
## ✔ lubridate 1.9.3 ✔ tidyr 1.3.1
## ✔ purrr 1.0.2
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
file_path <- "wfp_commodities_global.csv"
data <- read.csv(file_path)
category_counts <- data %>%
group_by(category) %>%
summarise(count = n())
category_counts
## # A tibble: 9 × 2
## category count
## <chr> <int>
## 1 #item+type 1
## 2 cereals and tubers 271
## 3 meat, fish and eggs 158
## 4 milk and dairy 28
## 5 miscellaneous food 127
## 6 non-food 121
## 7 oil and fats 51
## 8 pulses and nuts 110
## 9 vegetables and fruits 265
category_counts <- data %>%
group_by(category) %>%
summarise(count = n())
category_counts
## # A tibble: 9 × 2
## category count
## <chr> <int>
## 1 #item+type 1
## 2 cereals and tubers 271
## 3 meat, fish and eggs 158
## 4 milk and dairy 28
## 5 miscellaneous food 127
## 6 non-food 121
## 7 oil and fats 51
## 8 pulses and nuts 110
## 9 vegetables and fruits 265
library(ggplot2)
ggplot(category_counts, aes(x = reorder(category, -count), y = count)) +
geom_bar(stat = "identity", fill = "skyblue") +
theme_minimal() +
labs(title = "Commodity Counts by Category",
x = "Category",
y = "Count") +
theme(axis.text.x = element_text(angle = 45, hjust = 1))
