Exploring the Electricity Crisis in Puerto Rico
Learning Outcomes
By the end of this lab, you should be able to: - Explain how electricity reliability data can be used to describe the ongoing electricity crisis in Puerto Rico. - Explain how SAIDI and SAIFI measure different aspects of electricity reliability. - Use filter(), mutate(), and select() to clean and prepare data. - Use pivot_longer() to reshape data for visualization. - Use summarize() to calculate average reliability measures across states. - Use bind_rows() to combine comparable data frames. - Create and interpret stacked bar charts using ggplot2. - Compare electricity reliability in Puerto Rico with reliability across the 50 U.S. states.
Background
Night Before - Read Forbes Article
Read the short Forbes article Puerto Rico’s Electric Grid Still In Crisis 9 Years After Maria.
The U.S. Energy Information Administration published an article with the headline “Even without hurricanes, customers in Puerto Rico lose about 27 hours of power per year” on August 13, 2025. In this lab, we will work with 2024 electricity reliability data related to the visualizations in that article. In 2024 specifically, Puerto Rico customers experienced more than 73 hours of interruptions on average, including interruptions from major events such as hurricanes. Our goal is to separate typical outage time from major-event-related outage time.
Lab Goal
Understand the U.S. Energy Information Administration data and create stacked bar graphs for 2024 that compare electricity reliability in Puerto Rico to reliability across the 50 U.S. states.
Libraries
In this activity we will be using functions from dplyr, readr, and ggplot. All of these libraries are part of the tidyverse.
Read Data
The electricity reliability information for the 50 U.S. states and U.S. territories is stored in two different data files.
Video explaining the data: https://www.youtube.com/watch?v=oVH9L0fCMTU.
Each cleaned data file provided contain electricity reliability measures for U.S. states or U.S. territories in 2024.
Download the data files here:
Data Dictionary
| Variable | Description |
|---|---|
year |
The year the data were collected. In this activity, the data are from 2024. |
State |
The state or territory included in the data. |
SAIDI_min_all_events |
Average outage duration in minutes per customer, including both typical outages and major event days. |
SAIDI_min_without_major |
Average outage duration in minutes per customer, excluding major event days. |
SAIFI_count_all_events |
System Average Interruption Frequency Index, measured as the number of interruptions per customer per year, including all events. This represents how often customers lost power during the year, on average. |
SAIFI_count_without_major |
System Average Interruption Frequency Index, measured as the number of interruptions per customer per year, excluding major event days. This represents how often customers lost power during more typical operating conditions. |
The difference between SAIDI_min_all_events and SAIDI_min_without_major estimates the outage duration attributed to major events.
Note: SAIDI measures the duration of outages, while SAIFI measures the frequency of outages. In other words, SAIDI asks “How long was the power out?” and SAIFI asks “How often did the power go out?”
Read the U.S. Energy Information Administration article and interpret the graph “Puerto Rico average duration of annual electricity interruptions (2021-2024) number of hours per customer.”
Use the glimpse() and View() functions to take a look at the US territories data.
Look the glimpse results and browse the data in view window. Click on the column headers in the view window to sort the data by various variables to see more of the data. Do you notice anything about the territory data that may require data cleaning or manipulations?
Note that NA’s will always be sorted to the bottom of the view window.
Use the glimpse() function to take a look at the US states data.
Look at the glimpse results and browse the data in view window. Click on the column headers in the view window to sort the data by various variables to see more of the data. Do you notice anything about the states data that may require data cleaning or manipulations?
Visualizing Puerto Rico Average Hourly Interruptions
Beyond any cleaning steps describe what data manipulations will need to be completed in order to make a data ggplot stacked bar chart that compares Puerto Rico’s average number of hours each customer experienced electricity interruptions with and without major events.
We only need to compare the states data to Puerto Rico, not all U.S. territories. filter the territories to only include Puerto Rico.
Use a mutate() to create new columns
- major_event_minutes: estimated outage minutes attributed to major events
- ave_typical_outage_hours: average outage hours excluding major events
- ave_outage_major_event_hours: average outage hours attributed to major events
- major_event_minutes: estimated outage minutes attributed to major events
Use the results of the prior question, create a stacked bar chart of the average number of hours each customer in Puerto Rico experienced electricity interruptions with and without major events in 2024. Since both values we want in our bar are in two different columns, we need to pivot_longer() to create a row of the disruption duration with and without major events. See ?pivot_longer() but you only need to specify the cols argument with vector (
c()) of column names.
geom_col expects an \(x\) and \(y\) defined in the mapping (aes), but, you can set \(y\) to be an empty string (““).
Summarizing Across States
Next, we want to add a stacked bar of the average hours of electricity interruptions per customer across the 50 states. The state codes for the 50 US states are available in R, state.abb. Write a single pipe that does the following and save it as states_24ave.
- Filters the states_rel24 data to only include the 50 US states.
- Creates a new column major_event_minutes for all 50 US states.
- Calculate the average outage hours across the 50 states:
- ave_outage_major_event_hours: average outage hours attributed to major events
- ave_typical_outage_hours: average outage hours excluding major events
- Create a new column called State that has one value “US Average”; You will see why next.
Comparing Puerto Rico and the 50 U.S. States
- Use the two data frames, pr_rel24, and states_24ave, create a new data frame, stacked_rel24, by stacking the two using a bind_rows. Before you can stack them, it is best practice to make sure they share the same column names, otherwise
NAs will be added.
Only the State and averages you calculated are going to be needed to create the final visual.
Use this newly created data frame, stacked_rel24, to create side-by-side stacked bar charts comparing the average hours of electricity interruption per customer in 2024, during and not during major events, comparing Puerto Rico to the 50-state US averages.
Now, make your final data visualization look as close-as-possible to the first visual presented or first two visuals presented in the EIA article for 2024. Your goal is to create a visual that could be added to the article.
This will require using some ggplot code not covered in the course. Cite any online sources you use code from.
- Now provide a final interpretation of your new visual. Your interpretation should be in the same style as the article is written. Ideally, so that the EIA could include your new visual and interpretation as part of their article in the future.