https://github.com/leonawicz/rtrek
R package for Star Trek datasets and related R functions.
https://github.com/leonawicz/rtrek
data r-package stapi star-trek
Last synced: 5 months ago
JSON representation
R package for Star Trek datasets and related R functions.
- Host: GitHub
- URL: https://github.com/leonawicz/rtrek
- Owner: leonawicz
- License: other
- Created: 2018-05-15T23:54:00.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2025-06-20T00:14:21.000Z (7 months ago)
- Last Synced: 2025-09-04T18:58:00.508Z (5 months ago)
- Topics: data, r-package, stapi, star-trek
- Language: R
- Homepage: https://leonawicz.github.io/rtrek/
- Size: 21.8 MB
- Stars: 57
- Watchers: 7
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.Rmd
- Changelog: NEWS.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Codemeta: codemeta.json
Awesome Lists containing this project
README
---
output: github_document
---
```{r setup, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE, comment = "#>", fig.path = "man/figures/README-",
message = FALSE, warning = FALSE, error = FALSE
)
```
# rtrek 
[](https://www.repostatus.org/)
[](https://github.com/leonawicz/rtrek/actions/workflows/R-CMD-check.yaml)
[](https://app.codecov.io/gh/leonawicz/rtrek)
[](https://CRAN.R-project.org/package=rtrek)
[](https://cran.r-project.org/package=rtrek)
[](https://github.com/leonawicz/rtrek)
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](http://stapi.co/) (STAPI), [Memory Alpha](https://memory-alpha.fandom.com/wiki/Portal:Main) and [Memory Beta](https://memory-beta.fandom.com/wiki/Main_Page) 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](https://leonawicz.github.io/rtrek/articles/sc.html) using non-geographic Star Trek map tiles.*
## Installation
Install the CRAN release of `rtrek` with
``` r
install.packages("rtrek")
```
Install the development version from GitHub with
``` r
# install.packages("remotes")
remotes::install_github("leonawicz/rtrek")
```
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.
```{r ex, thm = knitr::knit_theme$get("molokai")}
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)
```
### Memory Alpha
Obtain content and metadata from the article about Spock on Memory Alpha:
```{r spock}
x <- ma_article("Spock")
x
x$metadata[[1]]$Born
```
### Memory Beta
Spock was born in 2230. Obtain a subset of the Star Trek universe historical timeline for that year:
```{r timeline}
mb_timeline(2230)
```
Live long and prosper.
## Packages in the trekverse
rtrek: The core Star Trek package
Datasets related to Star Trek, API wrappers to external data sources, and more.
lcars: LCARS aesthetic for Shiny
Create Shiny apps based on the Library Computer Access/Retrieval System (LCARS).
trekcolors: A color palette package
Predefined and customizable Star Trek themed color palettes and related functions.
## Citation
Matthew Leonawicz (`r substr(Sys.Date(), 1, 4)`). rtrek: Data analysis relating to Star Trek. R package version 0.5.2. https://CRAN.R-project.org/package=rtrek
## Contribute
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](https://github.com/leonawicz/rtrek/blob/master/CODE_OF_CONDUCT.md). By contributing to this project, you agree to abide by its terms.



