The ffpros package has several configuration options, most of which control default behaviours for functions.
This option controls caching of requests, and is the only option that needs to be set before the package is loaded.
The available options are "memory"
(default),
"filesystem"
(persistent between R sessions), and
"off"
.
Pages are stored for one (1) hour.
Basic example:
options(ffpros.cache = "memory")
options(ffpros.cache = "filesystem")
options(ffpros.cache = "off")
## THEN ##
library(ffpros) ## OR
ffpros::fp_rankings("consensus-cheatsheets")
You can use usethis::edit_r_profile()
to include this
option in your R profile, which will automatically load before the
ffpros package in future sessions.
This package respects the crawl delay set out in the robots.txt which asks
for five seconds per request. To change this configuration, you can use
the fp_set_ratelimit()
function:
The default sport for all ffpros functions is NFL. To change this,
you can set the ffpros.sport option, which needs to be one of
"nfl"
, "nba"
, "nhl"
, or
"mlb"
:
You can also use the fp_set_sport()
function to
accomplish the same thing:
You should not set this option in your rprofile, since it materially changes how ffpros operates - functions will start returning different output by default. Instead, always set it at the top of any required script.
By default, ffpros functions return only the cleaned data, but it can be configured to return the page HTML as well as any additional metadata, in case you want to parse the page on your own.
This can be set with either of the following two methods:
This function, as with the sport option, changes how ffpros functions behave in a material way - so you should not set this option in your rprofile. Instead, always set it at the top of any required script.
ffpros will default to identifying itself to FantasyPros.com as
"ffpros R client package https://github.com/ffverse/ffpros"
.
If you would like to pass a different user agent, you can configure this
with either of the following two methods:
There’s no significant difference between either of these methods and you can set it in your rprofile if you wish.