I am trying to create a connected scatterplot similar to the one and this has more explanation
Essentially, I am trying to show on one graph, the decline in the number of people within the labor force as measured by their numbers. The second graph would show changes in the unemployment rate within the same period.
This is my code:
# ggplot2 call:
Unemployment_Outflows %>%
ggplot( aes(x=unemployment_rate, y=labor, label=year)) +
# Custom the Y scales:
scale_y_continuous() +
geom_line( color="grey") +
geom_point(shape=21, color="black", fill="#69b3a2", size=3)
geom_segment(aes(
xend=c(tail(unemployment_rate, n=-1), NA),
yend=c(tail(labor, n=-1), NA)
)
)
However, as you can see, neither the lines nor a shaded area are visible, and I am getting the following error:
"geom_path: Each group consists of only one observation. Do you need to adjust the group aesthetic?"
year change change_perc unemployment_rate labor
*year (chr) labor unemployment_rate (dbl) (dbl)
Q4 2015 8416681 0 NA
Q4 2016 8492965 12.34717
Q4 2017 7907511 12.83452
Q4 2018 6895514 12.74767
Q4 2019 6437891 12.01787
Q3 2020 6409070 15.44732