library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## âś” dplyr 1.2.1 âś” readr 2.2.0
## âś” forcats 1.0.1 âś” stringr 1.6.0
## âś” ggplot2 4.0.3 âś” tibble 3.3.1
## âś” lubridate 1.9.5 âś” tidyr 1.3.2
## âś” purrr 1.2.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
library(readxl)
Cities <- read_xlsx("FiSC-Full-Dataset-2023-Update.xlsx")
This data set is an aggregation of local government level data over time to include population, revenues, and expenditures. All values representing dollar figures are per capita with the population of the locality at the time
summary(Cities$city_population)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 14914 66238 158083 303927 319569 8468954
The minimum population of cities in the data set is 14914 and the max being 8,468,954. The mean is 303,927
hist(Cities$city_population)
As can be seen here, the frequency of smaller cities compared to much larger cities skews the mean. This can be inferred as well from the median value being half of the mean.
plot(Cities$rev_general_city,Cities$spending_total_city)
The above graph shows total spending of municipalities compared to total revenue. As can be expected, as revenue increases, often total spending does as well. It should be noted there is a noticeable outlier that seems to that seems to be running their municipality with a sizable surplus.
cor(Cities$rev_general_city,Cities$spending_total_city)
## [1] 0.9153597
Despite the outlier, the correlation remains both positive and strong, as would be expected of this relationship
cor(Cities$transportation_city,Cities$city_population)
## [1] 0.1274595
Here I decided to see if the was a correlation between the size of a city and their spending on transportation. Surprisingly, it seems that the correlation between the two is rather weak.
plot(Cities$city_population,Cities$transportation_city)
Shown above is the visual representation transportation spending per capita and city population. As can be seen, costs do not seem to increase significantly as population rises. In fact, those with the highest per capita expenditures seem to have lower populations.
summary(Cities$transportation_city)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.0 142.5 218.3 295.5 342.3 5391.7
What can be seen with the graph is further cemented with the summary of the values. The vast majority of cities spend less than $1000 per resident, with the 3rd quartile being at $342.3. The max spending reaches $5391.7 per capita, far outpacing other municipalities in this area.
summary(Cities$tax_income_city)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.0 0.0 0.0 128.1 0.0 6391.3
Looking at income taxes also tells an interesting story in this dataset. It seems that the vast majorty of cities in the dataset do not collect an income tax at all, with the 1st quartile, median, and 3rd quartile all being 0. Yet the mean for this variable remains at $128.1. This can be explained somewhat due to the max being $6391.3, but it would be helpful to break it down further.
hist(Cities$tax_income_city)
The histogram shows that while there are a small number of cities that
issue income taxes to their resident. The vast majority levy no income
tax at all. Even among those that do, the number of cities that charge
over $2000 is so miniscule that they doesn’t appear visually on the
histogram.