-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.Rmd
140 lines (100 loc) · 3.41 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
---
output: github_document
editor_options:
chunk_output_type: console
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r setup, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
cache = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# speedrunr
<!-- badges: start -->
[![R-CMD-check](https://github.com/jemus42/speedrunr/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/jemus42/speedrunr/actions/workflows/R-CMD-check.yaml)
[![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)
[![No Maintenance Intended](http://unmaintained.tech/badge.svg)](http://unmaintained.tech/)
<!-- 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
pak::pak("jemus42/speedrunr")
```
## 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(speedrunr)
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.
```{r}
games <- get_games(name = "Ocarina of Time")
games %>%
select(id, name_international, name_abbr) %>%
head() %>%
kable()
```
Turns out `j1l9qz1g` is the id we're looking for.
### Get the game's categories
```{r}
categories <- get_categories(id = "j1l9qz1g")
categories %>%
select(id, name, type) %>%
head() %>%
kable()
```
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.
```{r}
runs <- get_runs(game = "j1l9qz1g", category = "q255jw2o")
glimpse(runs)
```
And now we can basically re-create the leaderboard, but including obsoleted runs:
```{r}
library(hms)
runs %>%
arrange(time_primary) %>%
head(20) %>%
select(submitted, time_primary, player_name) %>%
mutate(time_primary = hms(seconds = time_primary)) %>%
kable()
```
### More data
Wanna resolve those platforms? Just join with this table:
```{r}
get_platforms() %>%
head() %>%
kable()
```
Same can be done with regions:
```{r}
get_regions() %>%
kable()
```
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:
```{r}
runs %>%
add_regions() %>%
add_platforms() %>%
select(time_primary, system_region, system_platform) %>%
sample_n(5) %>%
knitr::kable()
```
## 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.