A speedrun.com API wrapper for R https://jemus42.github.io/speedrunr/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

3.3 KiB

output: github_document
chunk_output_type: console

<!-- README.md is generated from README.Rmd. Please edit that file -->

```{r setup, include = FALSE}
collapse = TRUE,
cache = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"

# speedrunr

<!-- badges: start -->
[![R build status](https://github.com/jemus42/speedrunr/workflows/R-CMD-check/badge.svg)](https://github.com/jemus42/speedrunr/actions)
[![CRAN status](https://www.r-pkg.org/badges/version/speedrunr)](https://cran.r-project.org/package=speedrunr)
[![GitHub release](https://img.shields.io/github/release/jemus42/speedrunr.svg?logo=GitHub)](https://github.com/jemus42/speedrunr/releases)
[![GitHub last commit (master)](https://img.shields.io/github/last-commit/jemus42/speedrunr/master.svg?logo=GithUb)](https://github.com/jemus42/speedrunr/commits/master)
<!-- badges: end -->

The goal of speedrunr is to easily access data from [speedrun.com](https://speedrun.com).

## Installation

You can install the released version of speedrunr from GitHub with:

``` r

## Example

Let's say you want to plot the times of all *Ocarina of TIme 100%* runs.
Let's get started:

```{r, message=FALSE, error=FALSE}
library(dplyr) # Data manip
library(knitr) # Tables

### Identifiyng the game you're looking for

You can either search for "Ocarina of Time", or supply `'oot'`, the game's abbreviation on speedrun.com.

games <- get_games(name = "Ocarina of Time")

games %>%
select(id, name_international, name_abbr) %>%
head() %>%

Turns out `j1l9qz1g` is the id we're looking for.

### Get the game's categories

categories <- get_categories(id = "j1l9qz1g")

categories %>%
select(id, name, type) %>%
head() %>%

So apparently we're looking for `q255jw2o`, the full-game 100% category.

### Get the runs in that category

Now we can fetch the runs. By default, 100 runs are returned, ordered by submit date in descending order, so newest runs first. This also means you will only be able to fully assess the WR progression if you make sure to get _all_ the runs.

runs <- get_runs(game = "j1l9qz1g", category = "q255jw2o")


And now we can basically re-create the leaderboard, but including obsoleted runs:


runs %>%
arrange(time_primary) %>%
head(20) %>%
select(submitted, time_primary, player_name) %>%
mutate(time_primary = hms(seconds = time_primary)) %>%

### More data

Wanna resolve those platforms? Just join with this table:

get_platforms() %>%
head() %>%

Same can be done with regions:

get_regions() %>%

There are also convenience functions to pipe your `runs` object into:

- `add_platforms()`
- `add_regions()`
- `add_players()`, which only makes on API call per unique player.

All of them work in the following way:

runs %>%
add_regions() %>%
add_platforms() %>%
select(time_primary, system_region, system_platform) %>%
sample_n(5) %>%

## Code of Conduct

Please note that this project is released with a [Contributor Code of Conduct](.github/CODE_OF_CONDUCT.md).
By participating in this project you agree to abide by its terms.