{"id":18174446,"url":"https://github.com/SCasanova/f1dataR","last_synced_at":"2025-04-01T15:31:37.168Z","repository":{"id":37254145,"uuid":"505617880","full_name":"SCasanova/f1dataR","owner":"SCasanova","description":"An R package to access Formula 1 Data from the Ergast API and the unofficial F1 data stream via the fastf1 python library.","archived":false,"fork":false,"pushed_at":"2025-03-27T01:03:17.000Z","size":44169,"stargazers_count":60,"open_issues_count":5,"forks_count":5,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-27T01:29:33.753Z","etag":null,"topics":["f1","formula1","r","r-package","rstats","sports-data"],"latest_commit_sha":null,"homepage":"https://scasanova.github.io/f1dataR/","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SCasanova.png","metadata":{"files":{"readme":"README.Rmd","changelog":"NEWS.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-06-20T22:37:19.000Z","updated_at":"2025-03-27T00:58:28.000Z","dependencies_parsed_at":"2024-01-29T16:45:57.530Z","dependency_job_id":"d168197e-d350-4f4d-b33b-090309e7922e","html_url":"https://github.com/SCasanova/f1dataR","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SCasanova%2Ff1dataR","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SCasanova%2Ff1dataR/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SCasanova%2Ff1dataR/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SCasanova%2Ff1dataR/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SCasanova","download_url":"https://codeload.github.com/SCasanova/f1dataR/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246662357,"owners_count":20813737,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["f1","formula1","r","r-package","rstats","sports-data"],"created_at":"2024-11-02T16:03:07.127Z","updated_at":"2025-04-01T15:31:32.155Z","avatar_url":"https://github.com/SCasanova.png","language":"R","funding_links":[],"categories":["R","Formula 1"],"sub_categories":["APIs and Libraries"],"readme":"---\noutput: github_document\nhtml_document:\n    includes:\n       in_header: GAfile.html\n---\n\n```{r, include = FALSE}\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  comment = \"#\u003e\",\n  fig.path = \"man/figures/README-\",\n  out.width = \"100%\",\n  dpi = 250,\n  dev = \"png\",\n  fig.width = 6,\n  fig.height = 4\n)\nlibrary(tibble)\noptions(\n  tibble.max_extra_cols = 10,\n  tibble.bold = TRUE,\n  tibble.print_max = 5,\n  pillar.min_title_width = 5\n)\nlibrary(f1dataR)\nwithr::local_timezone(\"UTC\")\n```\n\n# f1dataR \u003cimg src='man/figures/logo.png' align=\"right\" width=\"25%\" min-width=\"120px\"/\u003e\n\nAn R package to access Formula 1 Data from the Jolpica API (formerly Ergast) and the official F1 data stream via the FastF1 Python library.\n\n\u003c!-- badges: start --\u003e\n\n[![R-CMD-check](https://github.com/SCasanova/f1dataR/actions/workflows/check-standard.yaml/badge.svg)](https://github.com/SCasanova/f1dataR/actions/workflows/check-standard.yaml)\n[![test-coverage](https://github.com/SCasanova/f1dataR/actions/workflows/test-coverage.yaml/badge.svg)](https://github.com/SCasanova/f1dataR/actions/workflows/test-coverage.yaml)\n[![Codecov test coverage](https://img.shields.io/codecov/c/github/SCasanova/f1dataR?label=codecov\u0026logo=codecov)](https://app.codecov.io/gh/SCasanova/f1dataR?branch=main)\n[![Lifecycle: stable](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https://lifecycle.r-lib.org/articles/stages.html#stable)\n[![CRAN status](https://www.r-pkg.org/badges/version/f1dataR)](https://CRAN.R-project.org/package=f1dataR)\n[![CRAN downloads](https://cranlogs.r-pkg.org/badges/grand-total/f1dataR)](https://CRAN.R-project.org/package=f1dataR)\n \u003c!--badges: end --\u003e\n\n## Installation\n\nInstall the stable version from CRAN:\n```{r eval = FALSE}\ninstall.packages(\"f1dataR\")\n```\n\nor install the development version from GitHub:\n\n```{r eval = FALSE}\nif (!require(\"remotes\")) install.packages(\"remotes\")\nremotes::install_github(\"SCasanova/f1dataR\")\nlibrary(f1dataR)\n```\n\n## Data Sources\n\nData is pulled from:\n\n* [Jolpica F1 API](https://api.jolpi.ca/ergast/)\n* [F1 Data Stream](https://www.formula1.com/en/timing/f1-live) via the [Fast F1 python library](https://docs.fastf1.dev/index.html)\n\nNote the Ergast Motor Racing Database API will be shutting down at the end of 2024. A new data source (Jolpica-F1 project) was identified and implemented.\n\n## Functions\n\n### Load Lap Times\n\u003e `load_laps(season = \"current\", race = \"last\")`\n\nThis function loads lap-by-lap time data for all drivers in a given season\nand round. Round refers to race number. The defaults are current season and last race. Lap data is limited to 1996-present.\n\n**Example:**\n```{r load_laps}\nload_laps()\n```\n\nor\n\n```{r load_specific_laps}\nload_laps(season = 2021, round = 15)\n```\n\n\n### Driver Telemetry\n\u003e `load_driver_telemetry(season = \"current\", race = \"last\", session = \"R\", driver, laps = \"all\")`\n\nWhen the parameters for season (four digit year), round (number or GP name), session (FP1. FP2, FP3, Q, S, SS, 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\n\n```{r load_telemetries}\nload_driver_telemetry(season = 2022, round = 4, driver = \"PER\")\n\nload_driver_telemetry(season = 2018, round = 7, \"Q\", \"HAM\", laps = \"fastest\")\n```\n\n### Lap-by-Lap information\n\u003e `load_session_laps(season = \"current\", race = \"last\", session = \"R\", add_weather = FALSE)`\n\nThis function will give us detailed information of lap and sector times, tyres, weather (optional), and more for every lap of the GP and driver.\n\n```{r load_session_laps}\nload_session_laps(season = 2023, round = 4, add_weather = TRUE)\n```\n\n### Circuit Data\n\u003e `load_circuit_details(2023, 4)`\n\nThis function loads circuit details for a specific race session. Note that different track layouts are used at some circuits depending on the year of the race. Useful for visualizing or annotating data. Contains information on corners, marshal_lights and marshal_sectors.\n\n### Plotting\n\u003e `plot_fastest(season = \"current\", round = \"last\", session = \"R\", driver, color = \"gear\")`\n\nA built in plotting function that plots the circuit and a driver's fastest laps' `speed` or `gear` exists.\n\n```{r plot, eval=require('ggplot2', quietly = TRUE), message=FALSE, warning=FALSE}\nplot_fastest(season = 2023, round = 1, session = \"R\", driver = \"VER\", color = \"gear\")\n```\n\nTwo helper functions exist as well. The first, `theme_dark_f1()` assists with colour schemes similar to that used in other F1 graphics. The second, `correct_track_ratio()` is a function that fixes track ratio issues that appear when you create images similar to that above from `plot_fastest()`. Please refer to their documentation for usage.\n\n### Metadata Lookups\nThe package echos the metadata information look-up from the FastF1 package. this is a convenient way to programmatically look up drivers, teams, driver-team relationships, team colors, driver colors, tire types \u0026 colors and more. See the following functions for this look-up:\n\n* `get_driver_abbreviation()`\n* `get_driver_color()`\n* `get_driver_color_map()`\n* `get_driver_colour()`\n* `get_driver_colour_map()`\n* `get_driver_name()`\n* `get_driver_style()`\n* `get_driver_telemetry()`\n* `get_drivers_by_team()`\n* `get_session_drivers_and_teams()`\n* `get_team_by_driver()`\n* `get_team_color()`\n* `get_team_colour()`\n* `get_team_name()`\n* `get_tire_compounds()`\n\nNote that (in support of plotting functions) driver colors and marker type / line style can be retrieved from `get_driver_style()`. The function `get_driver_color()` will return the same color value for both drivers in a team. \n\n### Cache information\n\nThe cache directory for sessions can be set manually with the options function\n\n```{r cache_example, eval = FALSE}\noptions(f1dataR.cache = \"path/to/directory\")\n```\n\n### Other functions\n\nMany other functions exist, and are flexible enough to call the current `season` with the string `\"current\"` or use the year as a numeric value. Similarly, `round` can be `\"last\"` or a round number (from 1 to the total number of races in a season).\n\n* `load_constructors()`\n* `load_drivers(season = \"current\")`\n* `load_circuits(season = \"current\")`\n* `load_pitstops(season = \"current\", round = \"last\")`\n* `load_quali(season = \"current\", round = \"last\")`\n* `load_results(season = \"current\", round = \"last\")`\n* `load_schedule(season = ``r get_current_season()``)`\n* `load_sprint(season = \"current\", round = \"last\")`\n* `load_standings(season = \"current\", round = \"last\", type = c(\"driver\", \"constructor\"))`\n\n### Clear F1 Cache\n\u003e `clear_f1_cache()` \n\nClears the cache for all functions in the package.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSCasanova%2Ff1dataR","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FSCasanova%2Ff1dataR","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSCasanova%2Ff1dataR/lists"}