A curated list of open technology projects to sustain a stable climate, energy supply, biodiversity and natural resources.

owidR

An R Package for Interacting with Data from Our World in Data.
https://github.com/piersyork/owidR

Category: Sustainable Development
Sub Category: Data Catalogs and Interfaces

Keywords

data data-visualisation economics r r-package

Last synced: 34 minutes ago
JSON representation

Repository metadata

An R Package for Importing Data from Our World in Data

README.Rmd

          ---
title: "owidR"
output: github_document
always_allow_html: true
---

```{r, echo = FALSE, message=FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "##",
  fig.path = "inst/images/", fig.width=8.5, fig.asp=0.55, fig.align='center',
  message = FALSE
)

library(ggplot2)

ggplot2::theme_set(
  theme_minimal(base_family = "serif") %+replace%
    theme(text = element_text(colour = "#373737", size = 18),
          plot.title = element_text(size = "22", hjust = 0, vjust = 3.2, face = "bold"),
          plot.subtitle = element_text(hjust = 0, vjust = 3.5),
          plot.title.position = "plot",
          plot.caption.position = "plot",
          plot.caption = element_text(hjust = 0, size = 14, vjust = -1),
          legend.position = "right",
          axis.text = element_text(face = "plain"),
          axis.title.x = element_blank(),
          legend.title = element_blank(),
          panel.grid.major = element_line(linetype = "dashed"),
          panel.grid.minor = element_blank(),
          plot.margin = margin(11, 15, 8, 0),
          axis.line.x = element_line(colour = "#8e8e8e"),
          axis.ticks = element_line(colour = "#8e8e8e"))
)

```



![CRAN downloads](http://cranlogs.r-pkg.org/badges/grand-total/owidR) [![CRAN status](https://www.r-pkg.org/badges/version/owidR)](https://CRAN.R-project.org/package=owidR) 
[![R-CMD-check](https://github.com/piersyork/owidR/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/piersyork/owidR/actions/workflows/R-CMD-check.yaml)


This package acts as an interface to [Our World in Data](https://ourworldindata.org/) datasets, allowing for an easy way to search through data used in over 3,000 charts and load them into the R environment.

After some updates to the Our World in Data site, some of the previous parts of the package are no longer working. Please install the development version of the pacakage to maintain core functionality of the `owid()` function. The site also now provides an API, this may offer an easier way to download datasets into R without a dependency on this package. For example using just `data.table` you can easily download a specific dataset. See more information on the API here: [Our World in Data API](https://docs.owid.io/projects/etl/api/chart-api/#chart-data-api)  

```{r}
library(data.table)
life_expectancy <- fread("https://ourworldindata.org/grapher/life-expectancy.csv")
```


## Installation

To install from CRAN:

```{r eval=FALSE}
install.packages("owidR")
```

To install the development version from GitHub:

```{r eval = FALSE}
devtools::install_github("piersyork/owidR")
```

## Using the package

The main function in owidR is `owid()`, which takes a chart id and returns a data.table of the corresponding OWID dataset. To search for chart ids you can use `owid_search()` to list all the chart ids that match a keyword or regular expression.

## Example

Lets use the core functions to get data on how human rights have changed over time. First by searching for charts on human rights.

```{r example, eval = TRUE, message = FALSE}
library(owidR)

owid_search("human rights") # this function is no longer working

```

Let's use the v-dem human rights index dataset.

```{r example2, eval = TRUE, message = FALSE}

rights <- owid("human-rights-index-vdem", rename = "vdem_rights")

rights

```

ggplot2 makes it easy to visualise our data.

```{r plot}
library(ggplot2)
library(dplyr)

rights |> 
  filter(entity %in% c("United Kingdom", "France", "United States")) |> 
  ggplot(aes(year, vdem_rights, colour = entity)) +
  geom_line()
```

## COVID-19 Data

You can quickly download world covid-19 data, including vaccination rates, using `owid_covid()`.

```{r covid, eval=FALSE}
covid <- owid_covid()
```

## To-do

-   [ ] Add function to load multiple country datasets into one dataframe
-   [ ] Add caching of data (inc. backend)
-   [x] Remove interactive plotting to reduce dependencies
-   [ ] Create way to import owid explorers

        

GitHub Events

Total
Last Year

Committers metadata

Last synced: 7 days ago

Total Commits: 197
Total Committers: 2
Avg Commits per committer: 98.5
Development Distribution Score (DDS): 0.005

Commits in past year: 4
Committers in past year: 1
Avg Commits per committer in past year: 4.0
Development Distribution Score (DDS) in past year: 0.0

Name Email Commits
piersyork 8****k 196
Edouard Mathieu e****t@p****e 1

Committer domains:


Issue and Pull Request metadata

Last synced: 1 day ago

Total issues: 9
Total pull requests: 2
Average time to close issues: 26 days
Average time to close pull requests: about 2 hours
Total issue authors: 8
Total pull request authors: 2
Average comments per issue: 1.89
Average comments per pull request: 1.5
Merged pull request: 1
Bot issues: 0
Bot pull requests: 0

Past year issues: 3
Past year pull requests: 0
Past year average time to close issues: N/A
Past year average time to close pull requests: N/A
Past year issue authors: 3
Past year pull request authors: 0
Past year average comments per issue: 2.0
Past year average comments per pull request: 0
Past year merged pull request: 0
Past year bot issues: 0
Past year bot pull requests: 0

More stats: https://issues.ecosyste.ms/repositories/lookup?url=https://github.com/piersyork/owidR

Top Issue Authors

  • veggabo (2)
  • IvanWilli (1)
  • artod83 (1)
  • geertaarts (1)
  • aarondweinberg (1)
  • baifengbai (1)
  • luca-scr (1)
  • efsidi (1)

Top Pull Request Authors

  • veggabo (1)
  • edomt (1)

Top Issue Labels

Top Pull Request Labels


Package metadata

cran.r-project.org: owidR

Import Data from Our World in Data

  • Homepage: <https://github.com/piersyork/owidR>
  • Documentation: http://cran.r-project.org/web/packages/owidR/owidR.pdf
  • Licenses: MIT + file LICENSE
  • Latest release: 1.4.2 (published over 1 year ago)
  • Last Synced: 2025-04-26T13:33:32.260Z (1 day ago)
  • Versions: 9
  • Dependent Packages: 0
  • Dependent Repositories: 1
  • Downloads: 943 Last month
  • Rankings:
    • Stargazers count: 3.526%
    • Forks count: 6.822%
    • Average: 16.222%
    • Downloads: 18.314%
    • Dependent repos count: 23.796%
    • Dependent packages count: 28.652%
  • Maintainers (1)

Dependencies

DESCRIPTION cran
  • R >= 3.5.0 depends
  • curl * imports
  • dplyr * imports
  • forcats * imports
  • ggplot2 * imports
  • ggrepel * imports
  • grDevices * imports
  • htmltools * imports
  • httr * imports
  • jsonlite * imports
  • leaflet * imports
  • magrittr * imports
  • purrr * imports
  • readr * imports
  • rlang * imports
  • rvest * imports
  • scales * imports
  • sf * imports
  • stringr * imports
  • xml2 * imports
  • knitr * suggests
  • plm * suggests
  • rmarkdown * suggests
  • showtext * suggests
  • sysfonts * suggests
  • testthat >= 3.0.0 suggests
  • texreg * suggests
  • utils * suggests
.github/workflows/R-CMD-check.yaml actions
  • actions/checkout v2 composite
  • actions/upload-artifact main composite
  • r-lib/actions/check-r-package v1 composite
  • r-lib/actions/setup-pandoc v1 composite
  • r-lib/actions/setup-r v1 composite
  • r-lib/actions/setup-r-dependencies v1 composite

Score: 12.348353152786945