ggplot2 line plot: display latest values

In the following plot, how can I display the latest values of pop?

# toy data
df <- gapminder %>% 
  filter(country %in% c("Portugal", "Spain", "Japan", "Singapore"))
# plot
df %>% 
  ggplot(aes(x = year, y = pop, color = country)) +
  geom_line() +
  geom_point() +
  facet_wrap(~ continent)

Are you asking how to annotate the chart with text ?
If so, geom_text can be used, you can filter the data for the last points and add that data as a new layer with geom_text

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.