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:
Ensure fastf1 python package is installed. Please run this to install the most recent version: reticulate::py_install('fastf1')
Error in if (get_fastf1_version() < 3) { :
missing value where TRUE/FALSE needed
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 connectionused 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 callinglibrary(fastf1)
, and you can skip the rest of this guide.
reticulate
There are a few options to get the reticulate
set up in
a way that works well for f1dataR
to use it.
To use all of the defaults and set up the reticulate
package, you can use the below helper function.
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. For more
information on Python environments read this
article (infoworld.com).
If you’re comfortable with virtual environments and/or have one
already set up for fastf1, you can specify a virtualenv name/directory
with the above function. If it’s a Conda environment, setting the
conda
argument as true will use reticulate
s
interface for that in lieu of the one for virtualenv.
If you have repeat issues with the package failing to connect to your
proper environment, then before calling library(f1dataR)
or
using specific functions through ::
, add the following to
your code (replacing the envname
parameter with your actual
envname):
If you’ve used a Conda environment, call
reticulate::use_condaenv()
instead.