Author: Matthew Leonawicz gitter
License: MIT

CRAN status CRAN downloads Rdoc Travis-CI Build Status AppVeyor Build Status Coverage Status

The rtrek package provides datasets related to the Star Trek fictional universe and functions for working with those datasets. It interfaces with the Star Trek API (STAPI), Memory Alpha and Memory Beta to retrieve data, metadata and other information relating to Star Trek.

The package also contains several local datasets covering a variety of topics such as Star Trek timeline data, universe species data and geopolitical data. Some of these are more information rich, while others are toy examples useful for simple demonstrations. The bulk of Star Trek data is accessed from external sources by API. A future version of rtrek will also include summary datasets resulting from text mining analyses of Star Trek novels.

Note: This package is in beta (and not just the quadrant). Breaking changes may occur.

Image: Example Leaflet map using non-geographic Star Trek map tiles.


Installation

Install rtrek from CRAN with:

Install the development version of rtrek from GitHub with:

Examples

Time to be good detectives. Good thing Data has R installed.

These are just a few examples to help you jump right in. See the package articles for more.

STAPI

Use the Star Trek API (STAPI) to obtain information on the infamous character, Q. Specifically, retrieve data on his appearances and the stardates when he shows up. The first API call does a lightweight, unobtrusive check to see how many pages of potential search results exist for characters in the database. There are a lot of characters. The second call grabs only page two results. The third call uses the universal/unique ID uid to retrieve data on Q. Think of these three successive uses of stapi as safe mode, search mode and extraction mode.

library(rtrek)
library(dplyr)
stapi("character", page_count = TRUE)
#> Total pages to retrieve all results: 66

stapi("character", page = 2)
#> # A tibble: 100 x 24
#>    uid   name  gender yearOfBirth monthOfBirth dayOfBirth placeOfBirth
#>    <chr> <chr> <chr>        <int>        <int>      <int> <chr>       
#>  1 CHMA~ Robe~ <NA>            NA           NA         NA <NA>        
#>  2 CHMA~ Romu~ <NA>            NA           NA         NA <NA>        
#>  3 CHMA~ M. M~ <NA>            NA           NA         NA <NA>        
#>  4 CHMA~ Emir~ <NA>            NA           NA         NA <NA>        
#>  5 CHMA~ Tom ~ <NA>            NA           NA         NA <NA>        
#>  6 CHMA~ Aree~ <NA>            NA           NA         NA <NA>        
#>  7 CHMA~ Lursa <NA>            NA           NA         NA <NA>        
#>  8 CHMA~ Kons~ <NA>            NA           NA         NA <NA>        
#>  9 CHMA~ Harr~ <NA>            NA           NA         NA <NA>        
#> 10 CHMA~ Tezb~ <NA>            NA           NA         NA <NA>        
#> # ... with 90 more rows, and 17 more variables: yearOfDeath <int>,
#> #   monthOfDeath <lgl>, dayOfDeath <lgl>, placeOfDeath <chr>,
#> #   height <int>, weight <int>, deceased <lgl>, bloodType <chr>,
#> #   maritalStatus <chr>, serialNumber <lgl>, hologramActivationDate <chr>,
#> #   hologramStatus <chr>, hologramDateStatus <chr>, hologram <lgl>,
#> #   fictionalCharacter <lgl>, mirror <lgl>, alternateReality <lgl>

Q <- "CHMA0000025118" #unique ID
Q <- stapi("character", uid = Q)
Q$episodes %>% select(uid, title, stardateFrom, stardateTo)
#>              uid                 title stardateFrom stardateTo
#> 1 EPMA0000001458    All Good Things...      47988.0    47988.0
#> 2 EPMA0000000845                Q-Less      46531.2    46531.2
#> 3 EPMA0000001329                 Q Who      42761.3    42761.3
#> 4 EPMA0000000651              Tapestry           NA         NA
#> 5 EPMA0000001510    The Q and the Grey      50384.2    50392.7
#> 6 EPMA0000000483 Encounter at Farpoint      41153.7    41153.7
#> 7 EPMA0000162588            Death Wish           NA         NA
#> 8 EPMA0000001413                True Q      46192.3    46192.3
#> 9 EPMA0000001377                  Qpid      44741.9    44741.9