Learn R Programming

ffsimulator

The {ffsimulator} package uses bootstrap resampling to run fantasy football season simulations supported by historical rankings and nflfastR data, calculating optimal lineups, and returning aggregated results. This can quickly run your league through hundreds of seasons and builds out the data to help you study:

  • expected season finishes and range of outcomes
  • player contributions to season wins
  • roster constructions
  • effects of (potential) trades
  • and more!

This package is part of the ffverse family of R packages for fantasy football analysis.

Installation

Install the stable version of this package from CRAN:

install.packages("ffsimulator") # CRAN

Install the development version from either r-universe or GitHub:

install.packages("ffsimulator", repos = "https://ffverse.r-universe.dev")
# pak is recommended, see https://github.com/r-lib/pak
pak::pak("ffverse/ffsimulator")
# can also use remotes
remotes::install_github("ffverse/ffsimulator")

The development version has a separate documentation site here.

Usage

A season simulation can be run as follows:

library(ffsimulator)
library(ggplot2)
library(ggridges)

mfl_conn <- mfl_connect(season = 2021, league_id = 22627)

## OTHER PLATFORM CONNECTIONS MAY BE USED, FOR EXAMPLE:
# sleeper_conn <- sleeper_connect(season = 2021,  league_id = "652582284720971776") 
# flea_conn <- fleaflicker_connect(season = 2021, league_id = 312861) 
# espn_conn <- espn_connect(season = 2021, league_id = 899513)

mfl_sim <- ff_simulate(conn = mfl_conn, n_seasons = 100)

plot(mfl_sim)

Please also see the

vignettes for more detailed introductions.

Getting help

The best places to get help on this package are:

Contributing

Many hands make light work! Here are some ways you can contribute to this project:

Terms of Use

The R code for this package is released as open source under the MIT License. Fantasy football and NFL data accessed by this package belong to their respective owners, and are governed by their terms of use.

Copy Link

Version

Install

install.packages('ffsimulator')

Monthly Downloads

89

Version

1.2.3

License

MIT + file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Tan Ho

Last Published

February 12th, 2023

Functions in ffsimulator (1.2.3)

ff_starter_positions

Get league starter positions
ffs_build_schedules

Generate fantasy schedules
ffs_adp_outcomes_week

Connects ff_scoringhistory to past ADP rankings
ffs_add_replacement_level

Add replacement level players to each roster
ffs_adp_outcomes

Connects ff_scoringhistory to past ADP rankings
ffs_copy_template

Copy simulation template to filename
assert_columns

Check that dataframe has x column names
autoplot.ff_simulation

Automatically Plot ff_simulation Object
ffs_generate_projections

Generate Projections
ff_wins_added

Wins Added
ffs_schedule

Get Schedule
ffs_generate_projections_week

Generate Projections
ffs_starter_positions

Get league starter positions
fp_rankings_history_week

Historical position ranks
.ff_optimise_one_lineup

Optimise single lineup
ffs_latest_rankings

Download latest rankings from DynastyProcess GitHub
ffs_franchises

Get Franchises
ffs_rosters

Get Rosters
ffs_summarise_week

Summarise simulation outputs
ffs_optimise_lineups

Optimise Lineups
fleaflicker_connect

Connect to a league
sleeper_connect

Connect to a league
ffs_score_rosters

Join Rosters to Projected Scores
mfl_connect

Connect to a league
%>%

Pipe operator
fp_injury_table

FP injury table
fp_rankings_history

Historical draft position ranks
ffs_repeat_schedules

Repeat fantasy schedules
ffsimulator-package

ffsimulator: Simulate Fantasy Football Seasons
ff_simulate

Simulate Fantasy Seasons
ff_connect

Connect to a league
espn_connect

Connect to a league
autoplot.ff_simulation_week

Automatically Plot ff_simulation Object
.ff_apply_gp_model

Applies various injury models to adp outcomes
ff_scoringhistory

Get league scoring history
ff_simulate_week

Simulate Fantasy Week