Skip to contents

The main function of the package - uses bootstrap resampling to run fantasy football season simulations supported by historical rankings and nflfastR data, calculating optimal lineups, and returns aggregated results.

Usage

ff_simulate(
  conn,
  n_seasons = 100,
  n_weeks = 14,
  best_ball = FALSE,
  seed = NULL,
  gp_model = c("simple", "none"),
  base_seasons = 2012:2020,
  actual_schedule = FALSE,
  replacement_level = TRUE,
  pos_filter = c("QB", "RB", "WR", "TE", "K"),
  verbose = NULL,
  return = c("default", "all")
)

Arguments

conn

an connection to a league made with ff_connect() and friends (required)

n_seasons

number of seasons to simulate, default = 100

n_weeks

number of weeks per season, default = 14

best_ball

a logical: are weekly wins based on optimal lineups?

seed

an integer to control reproducibility

gp_model

select between "simple", "none" to apply a model for whether a player played in a given game, defaults to "simple"

base_seasons

a numeric vector that selects seasons as base data, earliest available is 2012

actual_schedule

a logical: use actual ff_schedule? default is FALSE

replacement_level

a logical: use best available on waiver as replacement level? defaults to TRUE

pos_filter

a character vector of positions to filter/run, default is c("QB","RB","WR","TE","K")

verbose

a logical: print status messages? default is TRUE, configure with options(ffsimulator.verbose)

return

one of c("default", "all") - what objects to return in the output list

Value

an ff_simulation object which can be passed to plot() and contains the output data from the simulation.

See also

vignette("basic") for example usage

vignette("custom") for examples on using the subfunctions for your own processes.

Examples

# \donttest{
try({ # try block to prevent CRAN-related issues
conn <- mfl_connect(2021, 22627)
ff_simulate(conn, n_seasons = 25)
})
#> ── Starting simulation 2022-08-11 12:57:51 ─────────────────────────────────────
#>  Importing data
#>  Importing data ... done
#> 
#>  Generating Projections
#>  Generating Projections ... done
#> 
#>  Calculating Roster Scores
#>  Calculating Roster Scores ... done
#> 
#>  Optimizing Lineups
#>  Optimizing Lineups ... done
#> 
#>  Building Schedules
#>  Building Schedules ... done
#> 
#>  Summarising Simulation Data
#>  Summarising Simulation Data ... done
#> 
#> ── Simulation complete! 2022-08-11 12:58:22 ────────────────────────────────────
#> <ff_simulation: 25 simulated seasons of Four-Eight Dynasty League>
#> List of 7
#>  $ summary_simulation:Classes ‘data.table’ and 'data.frame':	12 obs. of  11 variables:
#>  $ summary_season    :Classes ‘data.table’ and 'data.frame':	300 obs. of  12 variables:
#>  $ summary_week      :Classes ‘data.table’ and 'data.frame':	4200 obs. of  16 variables:
#>  $ roster_scores     :Classes ‘data.table’ and 'data.frame':	211806 obs. of  23 variables:
#>  $ projected_scores  :Classes ‘data.table’ and 'data.frame':	134806 obs. of  14 variables:
#>  $ league_info       : tibble [1 × 17] (S3: tbl_df/tbl/data.frame)
#>  $ simulation_params :List of 9
# }