knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", message = FALSE, warning = FALSE, error = FALSE )
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.
Image: Example Leaflet map using non-geographic Star Trek map tiles.
Install the CRAN release of rtrek
with
install.packages("rtrek")
Install the development version from GitHub with
# install.packages("remotes") remotes::install_github("leonawicz/rtrek")
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.
library(rtrek) library(dplyr) stapi("character", page_count = TRUE) stapi("character", page = 1) |> select(uid, name) Q <- "CHMA0000025118" #unique ID Q <- stapi("character", uid = Q) Q$episodes |> select(uid, title, stardateFrom, stardateTo)
Obtain content and metadata from the article about Spock on Memory Alpha:
x <- ma_article("Spock") x x$metadata[[1]]$Born
Spock was born in 2230. Obtain a subset of the Star Trek universe historical timeline for that year:
mb_timeline(2230)
Live long and prosper.
Matthew Leonawicz (r substr(Sys.Date(), 1, 4)
). rtrek: Data analysis relating to Star Trek. R package version 0.4.0. https://CRAN.R-project.org/package=rtrek
Contributions are welcome. Contribute through GitHub via pull request. Please create an issue first if it is regarding any substantive feature add or change.
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.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.