[This article was first published on free range statistics - R, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.With the conflict in Iran causing worldwide disruption to energy markets, I have both a work and personal interest in energy supply in Pacific islands, which led me to this blog post. Here I look at just two aspects of energy: electricity generation, and household cooking. Nothing fancy here, just accessing some data and drawing a couple of plots.Electricity generationHere is the source of electricity for Pacific island countries, plus Australia and New Zealand, collated by Our World In Data from Energy Institute data that ultimately comes from government estimates:There’s a pretty obvious story here: most of the Pacific is very dependent on “oil” (in the form of diesel) for generation of most of its electricity. There are some small steps towards renewables happening in recent years, but the vulnerability to a price or availability shock for diesel is pretty obvious.Here’s the code for producing that, using the valuable owidapi R package to access the Our World in Data API.#---------------Set up-----------------library(owidapi)library(tidyverse)library(countrycode)library(WDI)library(jsonlite)library(janitor)library(httr2)pic_codes