MyNixOS website logo
Description

Examples of Recursive Lists and Nested or Split Data Frames.

Recursive lists in the form of R objects, 'JSON', and 'XML', for use in teaching and examples. Examples include color palettes, Game of Thrones characters, 'GitHub' users and repositories, music collections, and entities from the Star Wars universe. Data from the 'gapminder' package is also included, as a simple data frame and in nested and split forms.

CRANstatus R-CMD-check Codecov testcoverage

repurrrsive

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.

Installation

You can install repurrrsive from CRAN like so:

install.packages("repurrrsive")

or from GitHub with:

# install.packages("devtools")
devtools::install_github("jennybc/repurrrsive")

Recursive list examples

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 30 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")
#>  [1] "Theon Greyjoy"      "Tyrion Lannister"   "Victarion Greyjoy" 
#>  [4] "Will"               "Areo Hotah"         "Chett"             
#>  [7] "Cressen"            "Arianne Martell"    "Daenerys Targaryen"
#> [10] "Davos Seaworth"     "Arya Stark"         "Arys Oakheart"     
#> [13] "Asha Greyjoy"       "Barristan Selmy"    "Varamyr"           
#> [16] "Brandon Stark"      "Brienne of Tarth"   "Catelyn Stark"     
#> [19] "Cersei Lannister"   "Eddard Stark"       "Jaime Lannister"   
#> [22] "Jon Connington"     "Jon Snow"           "Aeron Greyjoy"     
#> [25] "Kevan Lannister"    "Melisandre"         "Merrett Frey"      
#> [28] "Quentyn Martell"    "Samwell Tarly"      "Sansa Stark"

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):

  • Game of Thrones characters
  • Data on entities in the Star Wars universe
  • GitHub user and repo data
  • Sharla Gelfand’s music collection
  • Color palettes from Wes Anderson movies

Learn more at https://jennybc.github.io/repurrrsive/articles/.

Nested and split data frames

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
#> # A tibble: 142 × 3
#>    country     continent data             
#>    <fct>       <fct>     <list>           
#>  1 Afghanistan Asia      <tibble [12 × 4]>
#>  2 Albania     Europe    <tibble [12 × 4]>
#>  3 Algeria     Africa    <tibble [12 × 4]>
#>  4 Angola      Africa    <tibble [12 × 4]>
#>  5 Argentina   Americas  <tibble [12 × 4]>
#>  6 Australia   Oceania   <tibble [12 × 4]>
#>  7 Austria     Europe    <tibble [12 × 4]>
#>  8 Bahrain     Asia      <tibble [12 × 4]>
#>  9 Bangladesh  Asia      <tibble [12 × 4]>
#> 10 Belgium     Europe    <tibble [12 × 4]>
#> # … with 132 more rows
Metadata

Version

1.1.0

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows