knitr::opts_chunk$set( collapse = TRUE, comment = "#>", error = TRUE, fig.path = "README-" )
The repurrrsive package provides recursive lists that are handy when teaching or exampling functions such as purrr::map()
and the rectangling functions in the tidyr package.
The datasets are stored as R list, JSON, and XML to provide the full non-rectangular data experience.
Enjoy!
This package also includes the main data frame from the gapminder package in 3 different forms: simple data frame (no list-columns), data frame nested by country, and split into a named list of data frames.
You can install repurrrsive from CRAN like so:
install.packages("repurrrsive")
or from GitHub with:
# install.packages("pak") pak::pak("jennybc/repurrrsive")
repurrrsive contains several datasets that are recursive lists, both in the form of R objects and as JSON and/or XML files.
For example, got_chars
is a list with information on the r length(repurrrsive::got_chars)
point-of-view characters from the first five books in the Song of Ice and Fire series by George R. R. Martin.
Here's how to use purrr::map_chr()
to extract the character's names:
library(repurrrsive) library(purrr) map_chr(got_chars, "name")
Each set of recursive lists has its own article that gives a sense of what sort of manipulations can be demonstrated with the dataset(s):
Learn more at https://jennybc.github.io/repurrrsive/articles/.
The Gapminder data, from the gapminder package, is also here in various forms to allow practice of different styles of grouped computation.
For example, the gap_nested
dataset has one row per country, with a nested data
column containing longitudinal data for life expectancy, population, and GDP per capita.
gap_nested
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.