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.
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 2024-10-03 14:20:07.891551 ──────────────────────────────
#> ℹ 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! 2024-10-03 14:20:35.425485 ─────────────────────────────
#> <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': 170800 obs. of 23 variables:
#> $ projected_scores :Classes ‘data.table’ and 'data.frame': 93800 obs. of 14 variables:
#> $ league_info : tibble [1 × 17] (S3: tbl_df/tbl/data.frame)
#> $ simulation_params :List of 9
# }