Case Study: Democracy in Guatemala

Look at the case study of democracy in Guatemala.

Let’s explore another example of how to convert a data frame that isn’t in tidy format (wide format) to a data frame that’s in tidy format (long/narrow format). We’ll do this by using the pivot_longer() function from the tidyr package again.

Furthermore, we’ll use functions from the ggplot2 and dplyr packages to produce a time series plot showing how the democracy scores have changed over the 40 years from 1952 to 1992 for Guatemala. Recall that we saw time series plots on creating line graphs using geom_line().

Let’s use the dem_score data frame we imported before, but focus on only the data corresponding to Guatemala.

Get hands-on with 1400+ tech skills courses.