# Circular Bar Plot of Government Budget Percentage Allocation by Sector
# Sample Data from https://www.usaspending.gov/ (Simulated)
budget_data <- data.frame(
sector = c(
"Health Care",
"Defense",
"Education",
"Infrastructure",
"Social Welfare",
"Science & Technology",
"Environment",
"Transportation",
"Energy",
"Agriculture"
),
percentage = c(19, 26, 12, 8, 10, 6, 5, 7, 4, 3)
)
# Add id for each sector
budget_data <- budget_data %>%
arrange(desc(percentage)) %>%
mutate(id = row_number())
# Calculate the angle of each bar (to rotate labels accordingly)
number_of_bars <- nrow(budget_data)
angle <- 90 - 360 * (budget_data$id - 0.5) / number_of_bars # Calculate angle for labels
budget_data <- budget_data %>%
mutate(angle = angle,
hjust = ifelse(angle < -90, 1, 0), # Align labels properly
angle = ifelse(angle < -90, angle + 180, angle))