df <- read.csv("totals.csv")
str(df)
df2 <- filterD(df,Country %in% c("United States of America","China","Japan","Germany"))
df3 <- filterD(df2,rate>0)
df4 <- filterD(df3,Year>=2002,Year<=2016)
levels(df4$Country)[levels(df4$Country)=="United States of America"] ="United States"
crime <- read.csv("crime.csv")
str(crime)
The data from this graph comes from the United Nations Office on Drugs and Crime. The UNODC collects data about crime and the justice system in order to analyze and form conclusions that can be shared with the world to help form better policies. This data is collected through surveys across the world. I wanted to use this data to look at the number of people in prison in the most “developed” countries. After doing some research, I learned that in terms of countries, development just means that the country has a high GDP and a good economy.
I was curious to see if the countries that were similar in economic success were also similar in how they dealt with crime.
clrs <- c("United States"="#999999","China"="#56B4E9","Japan"="#009E73","Germany"="#F0E442")
mortgraph <- ggplot(data=df4,mapping=aes(x=Year,y=rate,
fill=Country)) +
geom_bar(stat="identity",color="black",)+
theme_bw() +
scale_fill_manual(values=clrs) +
scale_x_continuous(name="Year",breaks=seq(2000,2016,2)) +
scale_y_continuous(name="Total Persons Held in Prison per 100,000",expand=expansion(mult=c(0,0.05))) +
labs(title="Incarceration Rates in the World's Richest Countries",
caption="Data from https://dataunodc.un.org/data/prison/persons%20held%20total")
mortgraph
As I began to make the graph it became very apparent that the United States has a significantly higher rate of people in prison than the three other developed countries. While China and Germany are arguably almost the same, and with Japan slightly less, it is clear that the United States must have a very different way of dealing with crime than these other countries. Another trend that can be seen is the faint decline of the prison rate in the United States.
I used a stacked bar graph to display this data because it was the most effective way to portray the overwhelming rate of United States citizens that are in prison compared to China, Germany, and Japan. I chose these colors because they are easy to distinguish from one another, and colorblind friendly. I opted to not have a subtitle because it would not add anything to this graph.
This data is from the Uniform Crime Reporting Statistics database, which is a culmination of FBI crime statistics across the nation dating back to 1930. I chose to focus on New York, Illinois, Texas, and California because they contain the four largest cities in the United States by population, and more populated areas often contain higher rates of crime.
I wanted to know if and how the number of crimes has fluctuated over time.
clrs <- c("Texas"="#999999","California"="#56B4E9","Illinois"="#009E73","New York"="#F0E442")
crimegraph <- ggplot(data=crime,mapping=aes(x=Year,y=Crime.Total,
fill=State)) +
geom_bar(stat="identity",color="black")+
facet_wrap(vars(State),strip.position=c("right"),nrow=4) +
scale_x_continuous(name="Year",breaks=seq(1965,2014,5)) +
scale_y_continuous(name="Number of Crimes (in Thousands)",
labels=scales::unit_format(unit="",scale=1/1000),
expand=expansion(mult=c(0,0.05))) +
scale_fill_manual(values=clrs) +
theme_bw() +
theme(legend.position="none") +
labs(title="Number of Crimes Through the Years",
subtitle="In States with the Biggest Cities by Population",
caption="Data from https://www.ucrdatatool.gov/")
crimegraph
After crafting together this graph, I have come to the conclusion that the number of crimes peaked in all states around 1997, and then began to decline. This trend is most dramatically demonstrated by California and New York. Texas and Illinois show a milder version of this, and Texas plateaus at a higher point in relation to its starting point, than all other states.
I chose these colors because they are colorblind friendly and aesthetically pleasing. The bar graph was used because it displays the fluctuation in crime in the clearest way, and can be used to see the specific number of crimes quite easily. Lastly, faceting across the states and setting a universal range for the y-axis allowed for the best comparison between the states.