Setup FastF1 Connection

Introduction

This vignette briefly describes setting up the f1dataR package to work properly with with the Python package FastF1. This guide may help resolve some issues that might arise when you get the following warning or error messages:

If these happen to you (particularly if you’re a new user of f1dataR) read on!

f1dataR’s Relationship to Python

At the core of the f1dataR package, the connection to the Python package is created by using reticulate. This provides the connection used to call on Python and return objects to R. However, it has to be set up properly to work.

NOTE: If you are comfortable with reticulate, set up a virtualenv or condaenv and point reticulate to that with your .RProfile before calling library(fastf1), and you can skip the rest of this guide.

Setting up reticulate

There are a few options to get the reticulate set up in a way that works well for f1dataR to use it.

Accept all defaults

To use all of the defaults and set up the reticulate package, you can use the below helper function.

setup_fastf1()

This will create a virtual environment using your system’s default Python version, and install fastf1 in that python environment. It will also tell reticulate to use that environment instead of just running in your main system. Many resources exist online to explain python environments in more detail.

Repeat/Recurring Issues

If you have repeat issues with the package failing to connect to your proper environment, you can force a complete recreation of the virtual environment by calling:

setup_fastf1(new_env = TRUE)

If you’ve configured the package to use a custom environment name, the above function will require that name supplied as the envname parameter.