Skip to content

Commit

Permalink
New pkgdown site and small readme updates
Browse files Browse the repository at this point in the history
  • Loading branch information
gadenbuie committed Dec 8, 2022
1 parent 99667c9 commit 1421b5f
Show file tree
Hide file tree
Showing 7 changed files with 282 additions and 66 deletions.
3 changes: 3 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@
^\.github$
^tic\.R$
^CRAN-RELEASE$
^_pkgdown\.yml$
^docs$
^pkgdown$
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,4 @@ Network Trash Folder
Temporary Items
.apdisk
docs/
docs
6 changes: 4 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ Description: Provides data about the 'Star Wars' movie franchise in a set
of relational tables or as a complete 'DuckDB' database. All data was
collected from the open source 'Star Wars' API <https://swapi.dev/>.
License: MIT + file LICENSE
URL: https://github.com/gadenbuie/starwarsdb
URL: https://github.com/gadenbuie/starwarsdb,
https://pkg.garrickadenbuie.com/starwarsdb
BugReports: https://github.com/gadenbuie/starwarsdb/issues
Depends:
R (>= 2.10)
Expand All @@ -22,7 +23,8 @@ Suggests:
dm,
dplyr,
testthat
Config/Needs/website: any::DiagrammeR, any::DiagrammeRsvg
Config/Needs/website: any::DiagrammeR, any::DiagrammeRsvg,
gadenbuie/grkgdown
Encoding: UTF-8
LazyData: true
Roxygen: list(markdown = TRUE)
Expand Down
18 changes: 13 additions & 5 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ knitr::opts_chunk$set(

<!-- badges: start -->
[![CRAN status](https://www.r-pkg.org/badges/version/starwarsdb)](https://CRAN.R-project.org/package=starwarsdb)
[![tic status](https://github.com/gadenbuie/starwarsdb/workflows/tic/badge.svg)](https://github.com/gadenbuie/starwarsdb/actions)
[![R-CMD-check](https://github.com/gadenbuie/starwarsdb/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/gadenbuie/starwarsdb/actions/workflows/R-CMD-check.yaml)
<!-- badges: end -->

**starwarsdb** provides data from the [Star Wars API][swapi] as a set of relational tables, or as an in-package [DuckDB] database.

![](`r knitr::fig_chunk("starwars-data-model", "png")`)
![](man/figures/README-starwars-data-model-1.svg)

**Formats:**
[Metadata](#star-wars-data),
Expand Down Expand Up @@ -129,16 +129,24 @@ sw_dm
sw_dm %>%
dm_select_tbl(pilots, people) %>%
dm_filter("pilots", vehicle == "X-wing") %>%
dm_apply_filters() %>%
dm_filter(pilots = vehicle == "X-wing") %>%
dm_zoom_to("people") %>%
semi_join(pilots)
```

```{r starwars-data-model}
```{r starwars-data-model, eval = FALSE, echo = TRUE}
dm_draw(sw_dm)
```

![](man/figures/README-starwars-data-model-1.svg)

```{r starwars-data-model-write, echo = FALSE, eval = TRUE}
sw_dm %>%
dm_draw(graph_attrs = 'bgcolor="transparent"', node_attrs = 'fontname="Helvetica"') %>%
DiagrammeRsvg::export_svg() %>%
writeLines("man/figures/README-starwars-data-model-1.svg")
```

## API

For API access from R, check out the [rwars] package by Oliver Keyes.
Expand Down
120 changes: 61 additions & 59 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@

[![CRAN
status](https://www.r-pkg.org/badges/version/starwarsdb)](https://CRAN.R-project.org/package=starwarsdb)
[![tic status](https://github.com/gadenbuie/starwarsdb/workflows/tic/badge.svg)](https://github.com/gadenbuie/starwarsdb/actions)
[![R-CMD-check](https://github.com/gadenbuie/starwarsdb/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/gadenbuie/starwarsdb/actions/workflows/R-CMD-check.yaml)
<!-- badges: end -->

**starwarsdb** provides data from the [Star Wars API](https://swapi.dev)
as a set of relational tables, or as an in-package
[DuckDB](https://duckdb.org) database.

![](man/figures/README-starwars-data-model-1.png)
![](man/figures/README-starwars-data-model-1.svg)

**Formats:** [Metadata](#star-wars-data), [Local Tables](#local-tables),
[Remote Tables](#remote-tables), [Data Model (dm)](#dm-tables), [API
Expand Down Expand Up @@ -60,38 +60,38 @@ sourced from [SWAPI](https://swapi.dev).

``` r
schema
#> # A tibble: 5 x 4
#> endpoint endpoint_title endpoint_description properties
#> <chr> <chr> <chr> <list>
#> 1 films Film A Star Wars film <tibble [14 × 4…
#> 2 vehicles Starship A Starship or vehicle <tibble [19 × 4…
#> 3 species People A species within the Star Wars unive… <tibble [15 × 4…
#> 4 planets Planet A planet. <tibble [14 × 4…
#> 5 people People A person within the Star Wars univer… <tibble [16 × 4…
#> # A tibble: 5 × 4
#> endpoint endpoint_title endpoint_description properties
#> <chr> <chr> <chr> <list>
#> 1 films Film A Star Wars film <tibble>
#> 2 vehicles Starship A Starship or vehicle <gropd_df>
#> 3 species People A species within the Star Wars universe <tibble>
#> 4 planets Planet A planet. <tibble>
#> 5 people People A person within the Star Wars universe <tibble>
```

``` r
schema %>%
filter(endpoint == "films") %>%
pull(properties)
#> [[1]]
#> # A tibble: 14 x 4
#> variable type description format
#> <chr> <chr> <chr> <chr>
#> 1 starships array The starship resources featured within this fil… <NA>
#> 2 edited string the ISO 8601 date format of the time that this … date-t
#> 3 planets array The planet resources featured within this film. <NA>
#> 4 producer string The producer(s) of this film. <NA>
#> 5 title string The title of this film. <NA>
#> 6 url string The url of this resource uri
#> 7 release_date string The release date at original creator country. date
#> 8 vehicles array The vehicle resources featured within this film. <NA>
#> 9 episode_id integer The episode number of this film. <NA>
#> 10 director string The director of this film. <NA>
#> 11 created string The ISO 8601 date format of the time that this … date-t
#> 12 opening_cra… string The opening crawl text at the beginning of this… <NA>
#> 13 characters array The people resources featured within this film. <NA>
#> 14 species array The species resources featured within this film. <NA>
#> # A tibble: 14 × 4
#> variable type description format
#> <chr> <chr> <chr> <chr>
#> 1 starships array The starship resources featured within this fil… <NA>
#> 2 edited string the ISO 8601 date format of the time that this … date-…
#> 3 planets array The planet resources featured within this film. <NA>
#> 4 producer string The producer(s) of this film. <NA>
#> 5 title string The title of this film. <NA>
#> 6 url string The url of this resource uri
#> 7 release_date string The release date at original creator country. date
#> 8 vehicles array The vehicle resources featured within this film. <NA>
#> 9 episode_id integer The episode number of this film. <NA>
#> 10 director string The director of this film. <NA>
#> 11 created string The ISO 8601 date format of the time that this … date-…
#> 12 opening_crawl string The opening crawl text at the beginning of this… <NA>
#> 13 characters array The people resources featured within this film. <NA>
#> 14 species array The species resources featured within this film. <NA>
```

## Local Tables
Expand All @@ -101,7 +101,7 @@ Ask questions, like *who flew an X-Wing?*
``` r
x_wing_pilots <- pilots %>% filter(vehicle == "X-wing")
x_wing_pilots
#> # A tibble: 4 x 2
#> # A tibble: 4 × 2
#> pilot vehicle
#> <chr> <chr>
#> 1 Luke Skywalker X-wing
Expand All @@ -110,14 +110,15 @@ x_wing_pilots
#> 4 Jek Tono Porkins X-wing

people %>% semi_join(x_wing_pilots, by = c(name = "pilot"))
#> # A tibble: 4 x 11
#> name height mass hair_color skin_color eye_color birth_year gender homeworld
#> <chr> <dbl> <dbl> <chr> <chr> <chr> <dbl> <chr> <chr>
#> 1 Luke… 172 77 blond fair blue 19 mascu… Tatooine
#> 2 Bigg… 183 84 black light brown 24 mascu… Tatooine
#> 3 Wedg… 170 77 brown fair hazel 21 mascu… Corellia
#> 4 Jek … 180 110 brown fair blue NA mascu… Bestine …
#> # … with 2 more variables: species <chr>, sex <chr>
#> # A tibble: 4 × 11
#> name height mass hair_…¹ skin_…² eye_c…³ birth…⁴ gender homew…⁵ species
#> <chr> <dbl> <dbl> <chr> <chr> <chr> <dbl> <chr> <chr> <chr>
#> 1 Luke Skyw… 172 77 blond fair blue 19 mascu… Tatooi… Human
#> 2 Biggs Dar… 183 84 black light brown 24 mascu… Tatooi… Human
#> 3 Wedge Ant… 170 77 brown fair hazel 21 mascu… Corell… Human
#> 4 Jek Tono … 180 110 brown fair blue NA mascu… Bestin… Human
#> # … with 1 more variable: sex <chr>, and abbreviated variable names
#> # ¹​hair_color, ²​skin_color, ³​eye_color, ⁴​birth_year, ⁵​homeworld
```

## Remote Tables
Expand All @@ -133,7 +134,7 @@ people_rmt <- tbl(con, "people")
pilots_rmt <- tbl(con, "pilots")
pilots_rmt
#> # Source: table<pilots> [?? x 2]
#> # Database: duckdb_connection
#> # Database: DuckDB 0.6.1 [root@Darwin 22.1.0:R 4.2.2/:memory:]
#> pilot vehicle
#> <chr> <chr>
#> 1 Chewbacca Millennium Falcon
Expand All @@ -150,8 +151,8 @@ pilots_rmt

x_wing_pilots <- pilots_rmt %>% filter(vehicle == "X-wing")
x_wing_pilots
#> # Source: lazy query [?? x 2]
#> # Database: duckdb_connection
#> # Source: SQL [4 x 2]
#> # Database: DuckDB 0.6.1 [root@Darwin 22.1.0:R 4.2.2/:memory:]
#> pilot vehicle
#> <chr> <chr>
#> 1 Luke Skywalker X-wing
Expand All @@ -160,15 +161,16 @@ x_wing_pilots
#> 4 Jek Tono Porkins X-wing

people_rmt %>% semi_join(x_wing_pilots, by = c(name = "pilot"))
#> # Source: lazy query [?? x 11]
#> # Database: duckdb_connection
#> name height mass hair_color skin_color eye_color birth_year gender homeworld
#> <chr> <dbl> <dbl> <chr> <chr> <chr> <dbl> <chr> <chr>
#> 1 Luke… 172 77 blond fair blue 19 mascu… Tatooine
#> 2 Bigg… 183 84 black light brown 24 mascu… Tatooine
#> 3 Wedg… 170 77 brown fair hazel 21 mascu… Corellia
#> 4 Jek … 180 110 brown fair blue NA mascu… Bestine …
#> # … with 2 more variables: species <chr>, sex <chr>
#> # Source: SQL [4 x 11]
#> # Database: DuckDB 0.6.1 [root@Darwin 22.1.0:R 4.2.2/:memory:]
#> name height mass hair_…¹ skin_…² eye_c…³ birth…⁴ gender homew…⁵ species
#> <chr> <dbl> <dbl> <chr> <chr> <chr> <dbl> <chr> <chr> <chr>
#> 1 Luke Skyw… 172 77 blond fair blue 19 mascu… Tatooi… Human
#> 2 Biggs Dar… 183 84 black light brown 24 mascu… Tatooi… Human
#> 3 Wedge Ant… 170 77 brown fair hazel 21 mascu… Corell… Human
#> 4 Jek Tono … 180 110 brown fair blue NA mascu… Bestin… Human
#> # … with 1 more variable: sex <chr>, and abbreviated variable names
#> # ¹​hair_color, ²​skin_color, ³​eye_color, ⁴​birth_year, ⁵​homeworld
```

## DM Tables
Expand All @@ -190,26 +192,26 @@ sw_dm

sw_dm %>%
dm_select_tbl(pilots, people) %>%
dm_filter("pilots", vehicle == "X-wing") %>%
dm_apply_filters() %>%
dm_filter(pilots = vehicle == "X-wing") %>%
dm_zoom_to("people") %>%
semi_join(pilots)
#> # Zoomed table: people
#> # A tibble: 4 x 11
#> name height mass hair_color skin_color eye_color birth_year gender homeworld
#> <chr> <dbl> <dbl> <chr> <chr> <chr> <dbl> <chr> <chr>
#> 1 Luke… 172 77 blond fair blue 19 mascu… Tatooine
#> 2 Bigg… 183 84 black light brown 24 mascu… Tatooine
#> 3 Wedg… 170 77 brown fair hazel 21 mascu… Corellia
#> 4 Jek … 180 110 brown fair blue NA mascu… Bestine …
#> # … with 2 more variables: species <chr>, sex <chr>
#> # A tibble: 4 × 11
#> name height mass hair_…¹ skin_…² eye_c…³ birth…⁴ gender homew…⁵ species
#> <chr> <dbl> <dbl> <chr> <chr> <chr> <dbl> <chr> <chr> <chr>
#> 1 Luke Skyw… 172 77 blond fair blue 19 mascu… Tatooi… Human
#> 2 Biggs Dar… 183 84 black light brown 24 mascu… Tatooi… Human
#> 3 Wedge Ant… 170 77 brown fair hazel 21 mascu… Corell… Human
#> 4 Jek Tono … 180 110 brown fair blue NA mascu… Bestin… Human
#> # … with 1 more variable: sex <chr>, and abbreviated variable names
#> # ¹​hair_color, ²​skin_color, ³​eye_color, ⁴​birth_year, ⁵​homeworld
```

``` r
dm_draw(sw_dm)
```

<img src="man/figures/README-starwars-data-model-1.png" width="100%" />
![](man/figures/README-starwars-data-model-1.svg)

## API

Expand Down
31 changes: 31 additions & 0 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
url: https://pkg.garrickadenbuie.com/starwarsdb

template:
package: grkgdown

navbar:
components:
github:
icon: fab fa-github fa-lg
href: https://github.com/gadenbuie/starwarsdb

reference:
- title: Connect to the packaged Star Wars Database
contents:
- '`starwars_db`'
- '`starwars_dm`'
- title: Tables
description: >
These tables are included as data in the package so that you can compare
local workflows with the same workflow using a database.
contents:
- '`films`'
- '`films_people`'
- '`films_planets`'
- '`films_vehicles`'
- '`people`'
- '`pilots`'
- '`planets`'
- '`schema`'
- '`species`'
- '`vehicles`'
Loading

0 comments on commit 1421b5f

Please sign in to comment.