Three DataViz Examples

Maps, Democracy Trends, and UN Voting

September 14, 2026

Plan for Today

  • Go over three visualization examples on Posit Cloud
  • Make a map
  • Plot democracy over time
  • Plot UN voting trends

Let’s get going . . .


Let’s open up the Getting Started module on Posit Cloud…

And work through the examples there.

Example: Make a Map!

Example: Make a map!


library(leaflet)
leaflet() |>
  addTiles() |>   # Add default OpenStreetMap map tiles
  addMarkers(lat = 38.90243843683386, lng =  -77.0443814477152,
             label = "Elliott School of International Affairs")

Example: Plotting Democracy Over Time

Example: Plotting Democracy Over Time

# Load the packages
library(vdemlite)
library(ggplot2)

# Use vdemlite to extract democracy scores for France and INdia
dem_data <- fetchdem(indicators = "v2x_polyarchy",
                     countries = c("FRA", "IND"))

# And now we can plot the data
ggplot(dem_data, aes(y = v2x_polyarchy, x = year, color=country_name)) +
  geom_line() +
  theme_minimal() +
  xlab("Year") +
  ylab("Electoral Democracy Index") +
  ggtitle("Electoral Democracy, 1970-2022") +
  geom_hline(yintercept = .5, linetype = "dashed", color = "grey") +
   scale_color_manual(name="Country", values=c("#E69F00", "#56B4E9")) +
  ylim(0, 1)