Description Usage Arguments Value See Also Examples
View source: R/marcelBatting.R
Apply marcels for batters
1 2 | apply_marcel_batting(data, metric, age_adjustment_fun,
metric_weights = c(5, 4, 3), playing_time_weights = c(0.5, 0.1, 0))
|
data |
A data frame with batting stats, including seasonal averages. |
metric |
A string given the name of the metric to compute projections for, e.g. 'HR' |
age_adjustment_fun |
A callable to make the age adjustment |
metric_weights |
An array with the weights to give to the projected stats for the previous seasons. The ith elemnt is the weight for the season i years previous. The default is the c(5, 4, 3). |
playing_time_weights |
An array with the weights to be used for projecting playing time |
A data frame containg Marcel projections for 'metric'. The projection is given the generic name 'proj_value'.
apply_marcel_pitching
,
get_team_projected_batting
,
export_marcels
1 2 3 4 5 6 7 8 9 10 11 | a <- get_batting_stats() %>% filter(yearID>=2001, yearID<=2003) %>% filter(POS!="P")
b <- tbl_df(append_previous_years(a,
get_seasonal_averages_batting,
previous_years = 3))
mcl = apply_marcel_batting(b, "HR", age_adjustment)
mcl %>% filter(projectedYearID==2004, playerID=='beltrca01')
playerID yearID projectedYearID age_adj x_metric x_pa x_av proj_pa
1 beltrca01 2003 2004 1.006 318 7938 0.02867422 573.2
num denom proj_rate_raw proj_rate proj_value
1 352.4091 9138 0.03856523 0.03879662 22.23822
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.