|
Hall Of Famer
Join Date: Apr 2014
Posts: 2,282
|
New Top 100 Prospect List
In the future I would like to do some analysis on how prospects pan out and what matters most to their development. For now, I want to start with my own ranking of the top 100 prospects each year so that I can look at the data a little differently and be able to analyze past years. OOTP doesn't output the prospect list number in the database, so if I ever want to look at this, I'll have to calculate it myself. My numbers are slightly different than the ones the game calculates, but I wasn't trying to perfectly replicate their algorithm.
I take the talent_value for each player and then weight it based on age, development, personality, position, injury proneness, and whether or not a pitcher will rely on the changeup to develop into a starter. Then I adjust the resulting value based on if the player is a pitcher or not in order to rank the hitters and pitchers together. Currently the game is creating a lot more elite pitchers than hitters based on raw talent_value, which is why the drafts and prospect lists have been dominated by pitchers. This hopefully is due to the pitching-heavy nature of the 1960s and will soon change as hitting picks back up in the 70s. I believe there is something in the OOTP top 100 algorithm that will require a hitter at the 9th spot if one doesn't show up yet, but instead of doing it that way, I have decided to adjust for hitter/pitcher more generally.
Below is my raw code for calculating and creating the HTML table output for the top 100 lists and I welcome any suggestions to improving it as I'm trying to learn R.
Code:
```{r Top 100 prospects}
# Libraries ----
library(tidyverse)
library(kableExtra)
library(magick)
library(magrittr)
library(scales)
# Load Data ----
leagues <- read_csv('~/Out of the Park Developments/OOTP Baseball 20/saved_games/OOTPLeague.lg/import_export/general/leagues.csv')
players_roster_status <- read.csv.sql("~/Out of the Park Developments/OOTP Baseball 20/saved_games/OOTPLeague.lg/import_export/csv/players_roster_status.csv",
sql="select player_id, league_id, mlb_service_days from file group by player_id having league_id != 0 and league_id < 117 and mlb_service_days <= 45", eol = "\n")
players_career_batting_stats <- read.csv.sql("~/Out of the Park Developments/OOTP Baseball 20/saved_games/OOTPLeague.lg/import_export/csv/players_career_batting_stats.csv",
sql="select player_id, sum(ab) as ab from file group by player_id, league_id, split_id having league_id = 100 and split_id = 1 and sum(ab)<=130", eol = "\n")
players_career_pitching_stats <- read.csv.sql("~/Out of the Park Developments/OOTP Baseball 20/saved_games/OOTPLeague.lg/import_export/csv/players_career_pitching_stats.csv",
sql="select player_id, sum(ip) as ip from file group by player_id, league_id, split_id having league_id = 100 and split_id = 1 and sum(ip)<=50", eol = "\n")
players <- read.csv.sql("~/Out of the Park Developments/OOTP Baseball 20/saved_games/OOTPLeague.lg/import_export/csv/players.csv",
sql="select player_id, position, role, first_name, last_name, age, height, organization_id, bats, throws, personality_work_ethic, personality_intelligence, injury_left, prone_overall, running_ratings_speed, running_ratings_stealing, running_ratings_baserunning from file group by player_id having league_id != 0 and league_id < 117", eol = "\n")
players_value <- read.csv.sql("~/Out of the Park Developments/OOTP Baseball 20/saved_games/OOTPLeague.lg/import_export/csv/players_value.csv",
sql="select player_id, offensive_value, offensive_value_talent, pitching_value, pitching_value_talent, overall_value, talent_value, career_value, running_value, stealing_value, ratings_value, oa, pot from file group by player_id having league_id != 0 and league_id < 117", eol = "\n")
players_batting <- read.csv.sql("~/Out of the Park Developments/OOTP Baseball 20/saved_games/OOTPLeague.lg/import_export/csv/players_batting.csv",
sql="select player_id, batting_ratings_overall_contact, batting_ratings_overall_gap, batting_ratings_overall_eye, batting_ratings_overall_strikeouts, batting_ratings_overall_power, batting_ratings_talent_contact, batting_ratings_talent_gap, batting_ratings_talent_eye, batting_ratings_talent_strikeouts, batting_ratings_talent_power from file group by player_id having league_id != 0 and league_id < 117", eol = "\n")
players_pitching <- read.csv.sql("~/Out of the Park Developments/OOTP Baseball 20/saved_games/OOTPLeague.lg/import_export/csv/players_pitching.csv",
sql="select player_id, pitching_ratings_overall_stuff, pitching_ratings_overall_control, pitching_ratings_overall_movement, pitching_ratings_talent_stuff, pitching_ratings_talent_control, pitching_ratings_talent_movement, pitching_ratings_pitches_fastball, pitching_ratings_pitches_slider, pitching_ratings_pitches_curveball, pitching_ratings_pitches_screwball, pitching_ratings_pitches_forkball, pitching_ratings_pitches_changeup, pitching_ratings_pitches_sinker, pitching_ratings_pitches_splitter, pitching_ratings_pitches_knuckleball, pitching_ratings_pitches_cutter, pitching_ratings_pitches_circlechange, pitching_ratings_pitches_knucklecurve, pitching_ratings_pitches_talent_fastball, pitching_ratings_pitches_talent_slider, pitching_ratings_pitches_talent_curveball, pitching_ratings_pitches_talent_screwball, pitching_ratings_pitches_talent_forkball, pitching_ratings_pitches_talent_changeup, pitching_ratings_pitches_talent_sinker, pitching_ratings_pitches_talent_splitter, pitching_ratings_pitches_talent_knuckleball, pitching_ratings_pitches_talent_cutter, pitching_ratings_pitches_talent_circlechange, pitching_ratings_pitches_talent_knucklecurve, pitching_ratings_misc_velocity, pitching_ratings_misc_stamina from file group by player_id having league_id != 0 and league_id < 117", eol = "\n")
players_fielding <- read.csv.sql("~/Out of the Park Developments/OOTP Baseball 20/saved_games/OOTPLeague.lg/import_export/csv/players_fielding.csv",
sql="select player_id, fielding_ratings_infield_range, fielding_ratings_infield_arm, fielding_ratings_turn_doubleplay, fielding_ratings_outfield_range, fielding_ratings_outfield_arm, fielding_ratings_catcher_arm, fielding_ratings_catcher_ability, fielding_ratings_infield_error, fielding_ratings_outfield_error from file group by player_id having league_id != 0 and league_id < 117", eol = "\n")
velo_words <- velo_words <- read_csv("Out of the Park Developments/OOTP Baseball 20/saved_games/OOTPLeague.lg/import_export/general/velo_words.csv")
skill_lookup <- read_csv("Out of the Park Developments/OOTP Baseball 20/saved_games/OOTPLeague.lg/import_export/general/skill_lookup.csv")
# Build top_100 table ----
# Find which players are eligible
top_100 <- list(players_roster_status, players_career_batting_stats, players_career_pitching_stats) %>%
reduce(left_join, by = "player_id") %>%
select(player_id, league_id) %>%
# Reduce to top 100 ----
# Add in information about player and league
left_join(players, by="player_id") %>%
mutate_if(is.character, str_replace_all, pattern = '"', replacement='') %>%
# Add in player potential and current value from hitting, fielding, and pitching
list(players_value, players_batting, players_pitching, players_fielding) %>%
reduce(left_join, by = "player_id") %>%
mutate_if(is.numeric , replace_na, replace = 0) %>%
# Add calculated fields
mutate(p_def = (((fielding_ratings_infield_range - 125)/25*39.5) + ((fielding_ratings_infield_arm - 125)/25*6.5) + ((fielding_ratings_turn_doubleplay - 125)/25*3.25) + ((fielding_ratings_infield_error - 125)/25*15.75) + 308),
c_def = (((fielding_ratings_catcher_ability - 125)/25*19.5) + ((fielding_ratings_catcher_arm - 125)/25*19.5) + 133),
fb_def = (if_else(fielding_ratings_infield_range<=90,fielding_ratings_infield_range/3,30+(fielding_ratings_infield_range-90)*2/25) + if_else(fielding_ratings_infield_error<=90,fielding_ratings_infield_error/5,18+(fielding_ratings_infield_error-90)/25) + fielding_ratings_infield_arm/70 + fielding_ratings_turn_doubleplay/70)*(1 + (height-155)/15),
sb_def = (((fielding_ratings_infield_range - 125)/25*21.5) + ((fielding_ratings_infield_arm - 125)/25*1.5) + ((fielding_ratings_turn_doubleplay - 125)/25*9) + ((fielding_ratings_infield_error - 125)/25*8.25) + 129),
tb_def = (((fielding_ratings_infield_range - 125)/25*13) + ((fielding_ratings_infield_arm - 125)/25*17) + ((fielding_ratings_turn_doubleplay - 125)/25*3.25) + ((fielding_ratings_infield_error - 125)/25*7.5) + 113.5),
ss_def = (((fielding_ratings_infield_range - 125)/25*25.5) + ((fielding_ratings_infield_arm - 125)/25*2) + ((fielding_ratings_turn_doubleplay - 125)/25*8) + ((fielding_ratings_infield_error - 125)/25*7.5) + 93.75),
lf_def = (((fielding_ratings_outfield_range - 125)/25*29.5) + ((fielding_ratings_outfield_arm - 125)/25*5.75) + ((fielding_ratings_outfield_error - 125)/25*4) + 149),
cf_def = (((fielding_ratings_outfield_range - 125)/25*43) + ((fielding_ratings_outfield_arm - 125)/25*1.75) + ((fielding_ratings_outfield_error - 125)/25*3.5) + 78),
rf_def = (((fielding_ratings_outfield_range - 125)/25*25.5) + ((fielding_ratings_outfield_arm - 125)/25*11) + ((fielding_ratings_outfield_error - 125)/25*4) + 129),
current_pitches = rowSums(.[47:58] > 30),
pot_pitches = rowSums(.[59:70] > 30),
rely_change = if_else(pot_pitches == 3 &
pitching_ratings_pitches_changeup < 30 &
pitching_ratings_pitches_talent_changeup > 30,
"Y","N"),
ideal_pos = case_when(c_def > 0 ~ "C",
position == 1 & pitching_ratings_misc_stamina >=100 & pot_pitches >2 ~ "SP",
position == 1 & (pitching_ratings_misc_stamina <100 | pot_pitches <3) ~ "RP",
ss_def >= 100 ~ "SS",
cf_def >= 100 ~ "CF",
tb_def > 75 & tb_def > sb_def ~ "3B",
sb_def > 75 ~ "2B",
rf_def > 75 ~ "RF",
lf_def > 75 & lf_def > fb_def ~ "LF",
fb_def > 75 ~ "1B",
TRUE ~ "DH"
),
develop_adj = pmin(overall_value/talent_value,1),
age_adj = min(age)/age,
change_adj = ifelse(rely_change == "Y", 0, 1),
person_adj = ((personality_work_ethic/max(personality_work_ethic))+
(personality_intelligence/max(personality_intelligence)))/2) %>%
group_by(ideal_pos) %>%
mutate(pos_adj = talent_value/max(talent_value), inj_adj = min(prone_overall)/prone_overall) %>%
ungroup()
# Find range of talent value
tv_min <- min(top_100$talent_value)
tv_max <- max(top_100$talent_value)
#Adjustment by position
p_adj <- top_100 %>%
filter((ideal_pos == "SP"|ideal_pos == "RP")) %>%
top_n(100, talent_value) %>%
summarise(mean(talent_value)) %>%
pull()
oth_adj <- top_100 %>%
filter(!(ideal_pos == "SP"|ideal_pos == "RP")) %>%
top_n(100, talent_value) %>%
summarise(mean(talent_value)) %>%
pull()
if(p_adj>oth_adj){
oth_adj <- p_adj/oth_adj
p_adj <- 1
} else{
p_adj <- oth_adj/p_adj
oth_adj <- 1
}
# Calculate final adjusted_talent value and rescale
top_100 %<>%
mutate(talent_adj = 100+
10*(develop_adj+age_adj+change_adj+person_adj+
pos_adj+inj_adj),
adjusted_talent = ifelse(ideal_pos=="SP"|ideal_pos=="RP",
talent_adj*talent_value*p_adj,
talent_adj*talent_value*oth_adj)) %>%
arrange(desc(adjusted_talent))
top_100$adjusted_talent %<>% rescale(to=c(tv_min,tv_max))
# Reduce dataframe ----
top_100 %<>%
top_n(100, adjusted_talent)
# Extra information ----
top_100 %<>%
merge(leagues[,c("league_id", "abbr", "league_level")], by="league_id") %>%
rename(league_abbr=abbr) %>%
merge(teams[,c("team_id","abbr")], by.x = "organization_id", by.y = "team_id") %>%
merge(velo_words, by="pitching_ratings_misc_velocity") %>%
mutate(name=paste(first_name, last_name),
league_level = case_when(league_level == 1 ~ "MLB",
league_level == 2 ~ "AAA",
league_level == 3 ~ "AA",
league_level == 4 ~ "A",
league_level == 5 ~ "A-",
league_level == 6 ~ "R",
league_level == 7 ~ "IND",
league_level == 8 ~ "INT",
league_level == 10 ~ "COL",
league_level == 11 ~ "HS"),
bats = case_when(bats == 1 ~ "R",
bats == 2 ~ "L",
bats == 3 ~ "S"),
throws = if_else(throws == 1, "R", "L"),
position = case_when(position == 1 & role == 11 ~ "SP",
position == 1 & role != 11 ~ "RP",
position == 2 ~ "C",
position == 3 ~ "1B",
position == 4 ~ "2B",
position == 5 ~ "3B",
position == 6 ~ "SS",
position == 7 ~ "LF",
position == 8 ~ "CF",
position == 9 ~ "RF"),
rank = rank(-adjusted_talent),
def = case_when(ideal_pos == "SP" | ideal_pos == "RP" ~ p_def,
ideal_pos == "C" ~ c_def,
ideal_pos == "1B" ~ fb_def,
ideal_pos == "2B" ~ sb_def,
ideal_pos == "3B" ~ tb_def,
ideal_pos == "SS" ~ ss_def,
ideal_pos == "LF" ~ lf_def,
ideal_pos == "CF" ~ cf_def,
ideal_pos == "RF" ~ rf_def,
ideal_pos == "DH" ~ pmax(c_def,fb_def,sb_def,tb_def,
ss_def,lf_def,cf_def,rf_def)),
player_type = if_else(ideal_pos == "SP" | ideal_pos == "RP", "P","H")) %>%
arrange(desc(adjusted_talent))
current_pitch_names <- apply(top_100[which(colnames(top_100)=="pitching_ratings_pitches_fastball"):which(colnames(top_100)=="pitching_ratings_pitches_knucklecurve")], 1, function(x) paste(names(which(x >30)),collapse=", "))
top_100 <- cbind(top_100, current_pitch_names)
top_100$current_pitch_names <- gsub("pitching_ratings_pitches_", "", top_100$current_pitch_names)
pot_pitch_names <- apply(top_100[which(colnames(top_100)=="pitching_ratings_pitches_talent_fastball"):which(colnames(top_100)=="pitching_ratings_pitches_talent_knucklecurve")], 1, function(x) paste(names(which(x >30)),collapse=", "))
top_100 <- cbind(top_100, pot_pitch_names)
top_100$pot_pitch_names <- gsub("pitching_ratings_pitches_talent_", "", top_100$pot_pitch_names)
top_100$pot_pitch_names <- gsubfn("[a-z]+", list("fastball"="FB",
"slider"="SL",
"curveball"="CB",
"screwball"="SC",
"forkball"="FK",
"changeup"="CH",
"sinker"="SI",
"splitter"="SP",
"knuckleball"="KN",
"cutter"="CU",
"circlechange"="CC",
"knucklecurve"="KC"
), top_100$pot_pitch_names)
top_100$current_pitch_names <- gsubfn("[a-z]+", list("fastball"="FB",
"slider"="SL",
"curveball"="CB",
"screwball"="SC",
"forkball"="FK",
"changeup"="CH",
"sinker"="SI",
"splitter"="SP",
"knuckleball"="KN",
"cutter"="CU",
"circlechange"="CC",
"knucklecurve"="KC"), top_100$current_pitch_names)
# Create final output ----
out_top_100 <- top_100 %>%
select(Rank=rank, Name=name, Team=abbr, Age=age, Current_Position=position,
Ideal_Position=ideal_pos, batting_ratings_overall_contact,
batting_ratings_talent_contact, batting_ratings_overall_gap,
batting_ratings_talent_gap, batting_ratings_overall_power,
batting_ratings_talent_power, batting_ratings_overall_eye,
batting_ratings_talent_eye, batting_ratings_overall_strikeouts,
batting_ratings_talent_strikeouts, pitching_ratings_overall_stuff,
pitching_ratings_talent_stuff, pitching_ratings_overall_movement,
pitching_ratings_talent_movement,
pitching_ratings_overall_control, pitching_ratings_talent_control,
running_value, def, Level=league_level, current_pitch_names,
pot_pitch_names, player_type, Velocity=word, oa, pot) %>%
mutate(def = as.integer(round(def, digits = 0)))
# convert all of the contact/gap/etc ratings to the 20/80 scale
out_top_100[7:24] <- as.data.frame(lapply(out_top_100[7:24],function(col) skill_lookup$scouting[match(col,skill_lookup$skill)]))
# then color, add in the backslash view
out_top_100 <- out_top_100 %>%
mutate(oa = 5*round(oa/5,0), pot = 5*round(pot/5,0),
batting_ratings_overall_contact = cell_spec(batting_ratings_overall_contact, "html",
color = case_when(
batting_ratings_overall_contact < 35 ~ "red",
batting_ratings_overall_contact < 45 ~ "orange",
batting_ratings_overall_contact < 55 ~ "#ffe600",
batting_ratings_overall_contact < 70 ~ "green",
TRUE ~ "blue"
)),
batting_ratings_talent_contact = cell_spec(batting_ratings_talent_contact, "html",
color = case_when(
batting_ratings_talent_contact < 35 ~ "red",
batting_ratings_talent_contact < 45 ~ "orange",
batting_ratings_talent_contact < 55 ~ "#ffe600",
batting_ratings_talent_contact < 70 ~ "green",
TRUE ~ "blue"
)),
batting_ratings_overall_gap = cell_spec(batting_ratings_overall_gap, "html",
color = case_when(
batting_ratings_overall_gap < 35 ~ "red",
batting_ratings_overall_gap < 45 ~ "orange",
batting_ratings_overall_gap < 55 ~ "#ffe600",
batting_ratings_overall_gap < 70 ~ "green",
TRUE ~ "blue"
)),
batting_ratings_talent_gap = cell_spec(batting_ratings_talent_gap, "html",
color = case_when(
batting_ratings_talent_gap < 35 ~ "red",
batting_ratings_talent_gap < 45 ~ "orange",
batting_ratings_talent_gap < 55 ~ "#ffe600",
batting_ratings_talent_gap < 70 ~ "green",
TRUE ~ "blue"
)),
batting_ratings_overall_power = cell_spec(batting_ratings_overall_power, "html",
color = case_when(
batting_ratings_overall_power < 35 ~ "red",
batting_ratings_overall_power < 45 ~ "orange",
batting_ratings_overall_power < 55 ~ "#ffe600",
batting_ratings_overall_power < 70 ~ "green",
TRUE ~ "blue"
)),
batting_ratings_talent_power = cell_spec(batting_ratings_talent_power, "html",
color = case_when(
batting_ratings_talent_power < 35 ~ "red",
batting_ratings_talent_power < 45 ~ "orange",
batting_ratings_talent_power < 55 ~ "#ffe600",
batting_ratings_talent_power < 70 ~ "green",
TRUE ~ "blue"
)),
batting_ratings_overall_eye = cell_spec(batting_ratings_overall_eye, "html",
color = case_when(
batting_ratings_overall_eye < 35 ~ "red",
batting_ratings_overall_eye < 45 ~ "orange",
batting_ratings_overall_eye < 55 ~ "#ffe600",
batting_ratings_overall_eye < 70 ~ "green",
TRUE ~ "blue"
)),
batting_ratings_talent_eye = cell_spec(batting_ratings_talent_eye, "html",
color = case_when(
batting_ratings_talent_eye < 35 ~ "red",
batting_ratings_talent_eye < 45 ~ "orange",
batting_ratings_talent_eye < 55 ~ "#ffe600",
batting_ratings_talent_eye < 70 ~ "green",
TRUE ~ "blue"
)),
batting_ratings_overall_strikeouts = cell_spec(batting_ratings_overall_strikeouts, "html",
color = case_when(
batting_ratings_overall_strikeouts < 35 ~ "red",
batting_ratings_overall_strikeouts < 45 ~ "orange",
batting_ratings_overall_strikeouts < 55 ~ "#ffe600",
batting_ratings_overall_strikeouts < 70 ~ "green",
TRUE ~ "blue"
)),
batting_ratings_talent_strikeouts = cell_spec(batting_ratings_talent_strikeouts, "html",
color = case_when(
batting_ratings_talent_strikeouts < 35 ~ "red",
batting_ratings_talent_strikeouts < 45 ~ "orange",
batting_ratings_talent_strikeouts < 55 ~ "#ffe600",
batting_ratings_talent_strikeouts < 70 ~ "green",
TRUE ~ "blue"
)),
pitching_ratings_overall_stuff = cell_spec(pitching_ratings_overall_stuff, "html",
color = case_when(
pitching_ratings_overall_stuff < 35 ~ "red",
pitching_ratings_overall_stuff < 45 ~ "orange",
pitching_ratings_overall_stuff < 55 ~ "#ffe600",
pitching_ratings_overall_stuff < 70 ~ "green",
TRUE ~ "blue"
)),
pitching_ratings_talent_stuff = cell_spec(pitching_ratings_talent_stuff, "html",
color = case_when(
pitching_ratings_talent_stuff < 35 ~ "red",
pitching_ratings_talent_stuff < 45 ~ "orange",
pitching_ratings_talent_stuff < 55 ~ "#ffe600",
pitching_ratings_talent_stuff < 70 ~ "green",
TRUE ~ "blue"
)),
pitching_ratings_overall_movement = cell_spec(pitching_ratings_overall_movement, "html",
color = case_when(
pitching_ratings_overall_movement < 35 ~ "red",
pitching_ratings_overall_movement < 45 ~ "orange",
pitching_ratings_overall_movement < 55 ~ "#ffe600",
pitching_ratings_overall_movement < 70 ~ "green",
TRUE ~ "blue"
)),
pitching_ratings_talent_movement = cell_spec(pitching_ratings_talent_movement, "html",
color = case_when(
pitching_ratings_talent_movement < 35 ~ "red",
pitching_ratings_talent_movement < 45 ~ "orange",
pitching_ratings_talent_movement < 55 ~ "#ffe600",
pitching_ratings_talent_movement < 70 ~ "green",
TRUE ~ "blue"
)),
pitching_ratings_overall_control = cell_spec(pitching_ratings_overall_control, "html",
color = case_when(
pitching_ratings_overall_control < 35 ~ "red",
pitching_ratings_overall_control < 45 ~ "orange",
pitching_ratings_overall_control < 55 ~ "#ffe600",
pitching_ratings_overall_control < 70 ~ "green",
TRUE ~ "blue"
)),
pitching_ratings_talent_control = cell_spec(pitching_ratings_talent_control, "html",
color = case_when(
pitching_ratings_talent_control < 35 ~ "red",
pitching_ratings_talent_control < 45 ~ "orange",
pitching_ratings_talent_control < 55 ~ "#ffe600",
pitching_ratings_talent_control < 70 ~ "green",
TRUE ~ "blue"
)),
running_value = cell_spec(running_value, "html",
color = case_when(
running_value < 35 ~ "red",
running_value < 45 ~ "orange",
running_value < 55 ~ "#ffe600",
running_value < 70 ~ "green",
TRUE ~ "blue"
)),
def = cell_spec(def, "html",
color = case_when(
def < 35 ~ "red",
def < 45 ~ "orange",
def < 55 ~ "#ffe600",
def < 70 ~ "green",
TRUE ~ "blue"
)),
oa = cell_spec(oa, "html",
color = case_when(
oa < 35 ~ "red",
oa < 45 ~ "orange",
oa < 55 ~ "#ffe600",
oa < 70 ~ "green",
TRUE ~ "blue"
)),
pot = cell_spec(pot, "html",
color = case_when(
pot < 35 ~ "red",
pot < 45 ~ "orange",
pot < 55 ~ "#ffe600",
pot < 70 ~ "green",
TRUE ~ "blue"
)),
contact = paste0(batting_ratings_overall_contact,
"/",batting_ratings_talent_contact),
gap = paste0(batting_ratings_overall_gap,
"/",batting_ratings_talent_gap),
power = paste0(batting_ratings_overall_power,
"/",batting_ratings_talent_power),
eye = paste0(batting_ratings_overall_eye,
"/",batting_ratings_talent_eye),
avoid_k = paste0(batting_ratings_overall_strikeouts,
"/",batting_ratings_talent_strikeouts),
stuff = paste0(pitching_ratings_overall_stuff,
"/",pitching_ratings_talent_stuff),
movement = paste0(pitching_ratings_overall_movement,
"/",pitching_ratings_talent_movement),
control = paste0(pitching_ratings_overall_control,
"/",pitching_ratings_talent_control),
oapot = paste0(oa,
"/",pot)) %>%
group_by(player_type) %>%
group_split()
out_top_100[[1]] %<>%
select(Rank, Name, Team, Age, Current_Position,
Ideal_Position, oapot, contact, gap, power, eye, avoid_k, running_value,
def, Level)
out_top_100[[2]] %<>%
select(Rank, Name, Team, Age, Current_Position,
Ideal_Position, oapot, stuff, movement, control, Velocity, current_pitch_names,
pot_pitch_names, Level)
```
I'm having issues with the working directory saving in an RMD file, so I have to run the kable export function in an R script file instead.
Code:
# Hitter table
hitter_header <- c(15)
names(hitter_header) <- c(paste(max(leagues$season_year, na.rm = TRUE), "Top Hitters"))
kable(out_top_100[[1]], "html", align = rep('c', 15),
col.names = c("Rank", "Name", "Team", "Age",
"Current Position", "Ideal Position","OV/POT",
"Contact\n(OV/POT)","Gap\n(OV/POT)",
"Power\n(OV/POT)","Eye\n(OV/POT)",
"Avoid K's\n(OV/POT)","Running Value",
"Def","Level"), escape = FALSE,
linesep = "") %>%
add_header_above(header = hitter_header) %>%
kable_styling("striped", full_width = FALSE, font_size = 14) %>%
column_spec(2, width_min = "4.5cm") %>%
column_spec(1:15, extra_css = "padding: 0px;") %>%
save_kable("./OOTP/Extravaganza/Blog/top_100/hitter.png")
# Pitcher table
pitcher_header <- c(14)
names(pitcher_header) <- c(paste(max(leagues$season_year, na.rm = TRUE), "Top Pitchers"))
kable(out_top_100[[2]], "html", align = rep('c', 14),
col.names = c("Rank", "Name", "Team", "Age",
"Current Role", "Ideal Role","OV/POT",
"Stuff\n(OV/POT)","Movement\n(OV/POT)",
"Control\n(OV/POT)","Velocity","Current Pitches",
"Potential Pitches","Level"),escape = FALSE,
linesep = "") %>%
add_header_above(header = pitcher_header) %>%
kable_styling("striped", full_width = FALSE, font_size = 14) %>%
column_spec(2, width_min = "4.5cm") %>%
column_spec(11:13, width_min = "3.5cm") %>%
column_spec(1:14, extra_css = "padding: 0px;") %>%
save_kable("./OOTP/Extravaganza/Blog/top_100/pitcher.png")
Last edited by stealofhome; 07-01-2019 at 07:40 PM.
|