rtrek v0.2.0


Monthly downloads



Datasets and Functions Relating to Star Trek

Provides datasets related to the Star Trek fictional universe and functions for working with the data. The package also provides access to real world datasets based on the televised series and other related licensed media productions. It interfaces with the Star Trek API (STAPI) (<http://stapi.co/>), Memory Alpha (<http://memory-alpha.wikia.com/>), and Memory Beta (<http://memory-beta.wikia.com/>) to retrieve data, metadata and other information relating to Star Trek. It also contains several local datasets covering a variety of topics. The package also provides functions for working with data from other Star Trek-related R data packages containing larger datasets not stored in 'rtrek'.



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.


Install rtrek from CRAN with:


Install the development version of rtrek from GitHub with:

# install.packages("devtools")


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


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.

stapi("character", page_count = TRUE)
#> Total pages to retrieve all results: 64

stapi("character", page = 2)
#> # A tibble: 100 x 24
#>    uid   name  gender yearOfBirth monthOfBirth dayOfBirth placeOfBirth
#>    <chr> <chr> <chr>        <int> <lgl>        <lgl>      <chr>       
#>  1 CHMA~ Stev~ <NA>            NA NA           NA         <NA>        
#>  2 CHMA~ Yegg~ M               NA NA           NA         <NA>        
#>  3 CHMA~ Arex  M               NA NA           NA         <NA>        
#>  4 CHMA~ Jose~ M               NA NA           NA         <NA>        
#>  5 CHMA~ J. Z~ <NA>            NA NA           NA         <NA>        
#>  6 CHMA~ Doyle M               NA NA           NA         <NA>        
#>  7 CHMA~ Butl~ M               NA NA           NA         <NA>        
#>  8 CHMA~ Lito  M               NA NA           NA         <NA>        
#>  9 CHMA~ B. M~ <NA>            NA NA           NA         <NA>        
#> 10 CHMA~ Anna~ <NA>            NA NA           NA         <NA>        
#> # ... with 90 more rows, and 17 more variables: yearOfDeath <int>,
#> #   monthOfDeath <lgl>, dayOfDeath <lgl>, placeOfDeath <lgl>,
#> #   height <int>, weight <int>, deceased <lgl>, bloodType <lgl>,
#> #   maritalStatus <chr>, serialNumber <chr>, hologramActivationDate <lgl>,
#> #   hologramStatus <lgl>, hologramDateStatus <lgl>, 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 EPMA0000001329                 Q Who      42761.3    42761.3
#> 3 EPMA0000001377                  Qpid      44741.9    44741.9
#> 4 EPMA0000000483 Encounter at Farpoint      41153.7    41153.7
#> 5 EPMA0000000651              Tapestry           NA         NA
#> 6 EPMA0000000845                Q-Less      46531.2    46531.2
#> 7 EPMA0000162588            Death Wish           NA         NA
#> 8 EPMA0000001413                True Q      46192.3    46192.3
#> 9 EPMA0000001510    The Q and the Grey      50384.2    50392.7

Memory Alpha

Obtain content and metadata from the article about Spock on Memory Alpha:

x <- ma_article("Spock")
#> # A tibble: 1 x 4
#>   title content           metadata          categories       
#>   <chr> <list>            <list>            <list>           
#> 1 Spock <S3: xml_nodeset> <tibble [1 x 17]> <tibble [14 x 2]>
#> [1] "January 6, 2230 (stardate 2230.06)|ShiKahr, Vulcan"

Memory Beta

Spock was born in 2230. Obtain a subset of the Star Trek universe historical timeline for that year:

#> 2230
#> $events
#> # A tibble: 5 x 4
#>   period id            date  notes                                         
#>   <chr>  <chr>         <chr> <chr>                                         
#> 1 2230   Events        <NA>  Argelius II  and Betelgeuse become members of~
#> 2 2230   Births_and_D~ <NA>  Spock is born deep within a cave in Vulcan's ~
#> 3 2230   Births_and_D~ <NA>  George Samuel Kirk, Jr. is born.[5]           
#> 4 2230   Births_and_D~ <NA>  David Rabin is born.[6]                       
#> 5 2230   Births_and_D~ <NA>  Roy John Moss is born.[7]                     
#> $stories
#> # A tibble: 5 x 11
#>   title title_url colleciton collection_url section context series date 
#>   <chr> <chr>     <chr>      <chr>          <chr>   <chr>   <chr>  <chr>
#> 1 Burn~ Burning_~ <NA>       <NA>           Chapte~ <NA>    The O~ 2230 
#> 2 Star~ Star_Tre~ <NA>       <NA>           Chapte~ <NA>    The O~ 2230 
#> 3 IDW ~ IDW_Star~ Star Trek~ Star_Trek_(ID~ 2230 f~ <NA>    The O~ 2230 
#> 4 Star~ Star_Tre~ <NA>       <NA>           Chapte~ <NA>    The O~ 2230 
#> 5 Sarek Sarek_(n~ <NA>       <NA>           Chapte~ <NA>    The O~ 12 N~
#> # ... with 3 more variables: media <chr>, notes <chr>, image_url <chr>

Live long and prosper.

See the introduction vignette for more details and examples.


Complete package reference and function documentation

Please note that the rtrek project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.

Functions in rtrek

Name Description
ma_article Read Memory Alpha article
st_books_wiki Go to Wikipedia entry for a specific book series
ma_search Memory Alpha site search
st_datasets Available datasets
st_tiles_data Ancillary location data for map tiles
ma_image Memory Alpha images
mb_timeline Memory Beta timeline
mb_article Read Memory Beta article
%>% Pipe operator
st_font Preview Star Trek fonts
stGeo Raster grid location data for stellar cartographic map tile sets.
stapi Retrieve Star Trek data from STAPI
st_tiles Return the url associated with a tile set
mb_image Memory Beta images
stSeries Star Trek series.
rtrek rtrek: Star Trek datasets and related R functions.
memory_alpha Memory Alpha API
stapiEntities Star Trek API entities.
tile_coords Simple CRS coordinates
memory_beta Memory Beta API
stBooks Star Trek novel metadata.
stBooksWiki Star Trek novel metadata from Wikipedia.
stSpecies Species names and avatars, linked primarily from Memory Alpha.
tlFootnotes Star Trek timeline footnotes.
stTiles Available Star Trek map tile sets.
tlBooks Star Trek novel-based timeline.
tlEvents Star Trek event-based timeline.
mb_search Memory Beta site search
has_internet Check for internet connection
No Results!

Vignettes of rtrek

No Results!

Last month downloads


License MIT + file LICENSE
Encoding UTF-8
LazyData true
ByteCompile true
URL https://github.com/leonawicz/rtrek
BugReports https://github.com/leonawicz/rtrek/issues
VignetteBuilder knitr
RoxygenNote 6.1.1
NeedsCompilation no
Packaged 2019-01-11 16:13:39 UTC; Matt
Repository CRAN
Date/Publication 2019-01-11 17:20:03 UTC

Include our badge in your README