Module 10. Assignment
I learned how to use the ggplot2 package in R to show time-series data in this lesson. It taught me how good visual design can help turn raw data into stories that make sense after reading Visualize This by Nathan Yau and Selva Prabhakaran's Complete ggplot2 Tutorial
The built-in economics information shows changes in U.S. unemployment from 1967 to 2015, so I used it to make my own images for practice. I was interested in how mapping data could help people understand and make sense of long-term business trends.The code i have use in R
library(ggplot2)
library(gridExtra)
data("economics")
# Extract year for color mapping
economics$year <- as.integer(format(economics$date, "%Y"))
# 1. Line graphs: unemployment rate and median duration
plot1 <- qplot(date, unemploy / pop, data = economics, geom = "line") +
labs(title = "U.S. Unemployment Rate Over Time",
x = "Date", y = "Unemployed / Population")
plot2 <- qplot(date, uempmed, data = economics, geom = "line") +
labs(title = "Median Unemployment Duration (Weeks)",
x = "Date", y = "Weeks")
grid.arrange(plot1, plot2, ncol = 2)
# 2. Path plot: shows co-movement through time
p_path <- ggplot(economics, aes(x = unemploy / pop, y = uempmed)) +
geom_path(alpha = 0.6) +
geom_point(aes(color = year), size = 1.4) +
labs(title = "Unemployment Rate vs. Median Duration (Path Through Time)",
x = "Unemployed / Population", y = "Median Duration (weeks)", color = "Year") +
theme_minimal()
p_path
When you look at time-series data, visualization is very helpful because it helps you see patterns, trends, and connections that aren't clear from just looking at the numbers.
In my graphs, the line plots show how unemployment rate and duration fluctuate together over the decades, highlighting economic cycles such as recessions and recoveries.
A path plot, which links data points over time and colors them by year, shows how both factors change at the same time. For example, when unemployment goes up, so does the length of time people are out of work.
By visualizing the data, I could see right away how the patterns were repeating and how some years stood out. This was easy and quick to do with ggplot2, which let me try out different styles while keeping the plots clean and simple to read.
Using ggplot2, I worked on developing time-series visualizations in R for the purpose of completing this project. The economics dataset was the one I decided to utilize since it demonstrates actual changes in unemployment rates over time and seemed like it would be useful to work with. I began by creating two simple line graphs to examine the progression of the unemployment rate and the median length of unemployment from one year to the next. Subsequently, I constructed a route plot that linked both variables in order to demonstrate how they related to one another. With only a few lines of code, ggplot2 made it simple to construct graphs that were both tidy and professional. This was something that I truly appreciated. In the beginning, it was a little bit difficult to format the date axis and choose colors that looked appropriate. However, after some trial and error, I realized how much the nuances of the design can affect how clear the information is. It told a tale about how unemployment and job length rise and fall together throughout times of economic ups and downs. All things considered, this project visualization is not only about displaying data; rather, it is about conveying a narrative in a manner that is simple for other people to comprehend. In the event that I were to enhance my work, I would use comments or vertical lines for significant economic events such as recessions, and I may even investigate the utilization of interactive images in order to make it more interesting.
Comments
Post a Comment