forked from SCasanova/f1dataR
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.Rmd
96 lines (67 loc) · 2.64 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
---
output: github_document
html_document:
includes:
in_header: GAfile.html
---
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
library(tibble)
options(tibble.max_extra_cols = 10,
tibble.bold = TRUE,
tibble.print_max = 5,
pillar.min_title_width = 5)
```
# f1dataR <img src='man/figures/logo.png' align="right" width="25%" min-width="120px"/>
An R package to access Formula 1 Data from the Ergast API and the official F1 data stream via the fastf1 python library.
## Installation
```{r eval = FALSE}
if (!require("remotes")) install.packages("remotes")
remotes::install_github("SCasanova/f1dataR")
```
## Data Sources
Data is pulled from:
* [Ergast API](http://ergast.com/mrd/)
* [F1 Data Stream](https://www.formula1.com/en/f1-live.html) via the [Fast F1 python library](https://theoehrly.github.io/Fast-F1/index.html)
## Functions
### Load Lap Times
`load_laps(season = 'current', race = 'last')`
This function loads lap-by-lap time data for all drivers in a given season
and round. Round refers to race number. The defaults are current season and last race. Lap data is limited to 1996-present.
**Example:**
```{r}
library(f1dataR)
load_laps()
```
or
```{r}
load_laps(2021, 15)
```
### Driver Telemetry
`get_driver_telemetry(season = 'current', race = 'last', session = 'R', driver, fastest_only = FALSE)`
When the parameters for season (four digit year), race (number or GP name), session (FP1. FP2, FP3, Q or R), and driver code (three letter code) are entered, the function will load all data for a session and the pull the info for the selected driver. The first time a session is called, loading times will be relatively long but in subsequent calls this will improve to only a couple of seconds
```{r}
get_driver_telemetry(2022, 4, driver = 'PER')
get_driver_telemetry(2018, 7,'Q', 'HAM', fastest_only = T)
```
### Other funcitons
* `load_pitstops(season = 'current', race ='last')`
* `load_drivers(season = 2022)`
* `load_schedule(season = 2022)`
* `load_standings(season = 'current', round = 'last', type = c('driver', 'constructor'))`
* `load_results(season = 'current', round = 'last')`
* `load_quali(season = 'current', round = 'last')`
* `plot_fastest(season = 'current', race = 'last', driver, color = 'gear')`
### Clear F1 Cache
`clear_f1_cache()`
Clears the cache for all functions in the package.
## Loaded Data
The package also includes a static data frame for all current drivers and their respective constructors. Complete with team colors, logo and driver number logo.
```{r}
driver_constructor_data %>% colnames()
```