# yes, that is exactly it. thank you.
# curious as to your thoughts. I am attempting to create the inner and out shadow zone in # the dataframe. so I can isolate pitches that land in those zones.
# my initial approach is slow and tedious, but:
# I have started with simple ifelse statements that I intend or hope to join later:
gary_530191_samp$a <- ifelse((gary_530191_samp$plate_x <= 1.1) , 1 , 0)
gary_530191_samp$b <- ifelse((gary_530191_samp$plate_x >= 0.83) , 1 , 0)
### far left outer shadow
gary_530191_samp$d <- ifelse((gary_530191_samp$plate_x >= -1.1) , 1 , 0)
gary_530191_samp$e <- ifelse((gary_530191_samp$plate_x < -0.83) , 1 , 0)
### for upper outer shadow
gary_530191_samp$g <- ifelse((gary_530191_samp$plate_z <= 3.83) , 1 , 0)
gary_530191_samp$h <- ifelse((gary_530191_samp$plate_z > 3.5) , 1 , 0)
##### for bottom shadow
gary_530191$j <- ifelse((gary_530191$plate_z < 1.5) , 1 , 0)
gary_530191$k <- ifelse((gary_530191$plate_z >= 1.17) , 1 , 0)
# so I figure now I need to build something like for no2
gary_530191_samp %>%
mutate(shadow_outer = ifelse(
c(a = 1 | g = 1) ,
c(a = 1 | h = 1) ,
c(a = 1 | j = 1) ,
c(a = 1 | k = 1), 1 , 0)) -> gary_samp_530191
# but I believe there must be 1: a much easier way
# 2) something missing in the statement I have yet to try and enter(no2)
## I am curious of your thoughts to this approach
# also in my heart I believe these should have some value to make things easier
outerShadow <- data.frame(
x1 = c(OShdwIn , OShdwIn , OShdwOut , OShdwOut , OShdwIn) ,
y1 = c(OShdBot , OShdwTop , OShdwTop , OShdBot , OShdBot)
)
innerShadow <- data.frame(
x = c(IShdwIn , IShdwIn , IShdwOut , IShdwOut , IShdwIn) ,
y = c(IShdBot , IShdwtop , IShdwtop , IShdBot , IShdBot)
)
kZone <- data.frame(
x =c(inKzone , inKzone , outKzone , outKzone , inKzone),
y =c(botKzone , topKzone , topKzone , botKzone , botKzone)
)
## also . and thanks so much. I need to study the codes and the differences for the
## ggplots you sent later tonight.
## same data:
gary_530191_samp <- structure(list(catcher_name = structure(c(1063L, 1063L, 1063L,
1063L, 1063L, 1063L, 1063L, 1063L, 1063L, 1063L, 1063L, 1063L,
1063L, 1063L), .Label = c("A.J. Achter", "A.J. Cole", "A.J. Ellis",
"A.J. Griffin", "A.J. Jimenez", "A.J. Minter", "A.J. Morris",
"A.J. Pollock", "A.J. Ramos", "A.J. Reed", "A.J. Schugel", "Aaron Altherr",
"Aaron Barrett", "Aaron Blair", "Aaron Brooks", "Aaron Bummer",
"Aaron Crow", "Aaron Cunningham", "Aaron Harang", "Aaron Hicks",
"Aaron Hill", "Aaron Judge", "Aaron Laffey", "Aaron Loup", "Aaron Nola",
"Aaron Poreda", "Aaron Sanchez", "Aaron Slegers", "Aaron Thompson",
"Aaron Wilkerson", "Abel De Los Santos", "Abiatal Avelino", "Abraham Almonte",
"Adalberto Mejia", "Adam Cimber", "Adam Conley", "Adam Duvall",
"Adam Eaton", "Adam Engel", "Adam Frazier", "Adam Jones", "Adam Kolarek",
"Adam LaRoche", "Adam Liberatore", "Adam Lind", "Adam Loewen",
"Adam McCreery", "Adam Moore", "Adam Morgan", "Adam Ottavino",
"Adam Plutko", "Adam Rosales", "Adam Wainwright", "Adam Walker",
"Adam Warren", "Adam Wilk", "Adbert Alzolay", "Addison Reed",
"Addison Russell", "Adeiny Hechavarria", "Adolis Garcia", "Adonis Garcia",
"Adonis Medina", "Adrian Beltre", "Adrian Gonzalez", "Adrian Houser",
"Adrian Nieto", "Adrian Sampson", "Adrian Sanchez", "Adron Chambers",
"Akeel Morris", "Al Alburquerque", "Alan Busenitz", "Albert Abreu",
"Albert Almora Jr.", "Albert Pujols", "Albert Suarez", "Alberto Cabrera",
"Alberto Callaspo", "Alberto Gonzalez", "Alberto Rosario", "Alberto Tirado",
"Alcides Escobar", "Alec Asher", "Alec Mills", "Aledmys Diaz",
"Alejandro Chacin", "Alejandro De Aza", "Alen Hanson", "Alex Avila",
"Alex Blandino", "Alex Bregman", "Alex Burnett", "Alex Castellanos",
"Alex Claudio", "Alex Cobb", "Alex Colome", "Alex Dickerson",
"Alex Gordon", "Alex Guerrero", "Alex Hassan", "Alex Jackson",
"Alex Katz", "Alex Liddi", "Alex McRae", "Alex Mejia", "Alex Meyer",
"Alex Presley", "Alex Reyes", "Alex Rios", "Alex Sanabia", "Alex Torres",
"Alex Verdugo", "Alex White", "Alex Wilson", "Alex Wimmers",
"Alex Wood", "Alexei Ramirez", "Alexi Amarista", "Alexi Casilla",
"Alexi Ogando", "Alfredo Aceves", "Alfredo Figaro", "Alfredo Gonzalez",
"Alfredo Marte", "Alfredo Simon", "Ali Solis", "Allan Dykstra",
"Allen Cordoba", "Allen Craig", "Allen Webster", "Amed Rosario",
"Amir Garrett", "Anderson Espinoza", "Andre Ethier", "Andre Rienzo",
"Andrelton Simmons", "Andres Blanco", "Andres Machado", "Andres Torres",
"Andrew Albers", "Andrew Aplin", "Andrew Bailey", "Andrew Bellatti",
"Andrew Benintendi", "Andrew Brown", "Andrew Carignan", "Andrew Case",
"Andrew Cashner", "Andrew Chafin", "Andrew Edwards", "Andrew Faulkner",
"Andrew Heaney", "Andrew Kittredge", "Andrew Knapp", "Andrew Lambo",
"Andrew McCutchen", "Andrew McKirahan", "Andrew Miller", "Andrew Moore",
"Zac Curtis", "Zac Reininger", "Zac Rosscup", "Zach Borenstein",
"Zach Britton", "Zach Clark", "Zach Davies", "Zach Duke", "Zach Eflin",
"Zach Granite", "Zach Jemiola", "Zach Lee", "Zach Lovvorn", "Zach Lutz",
"Zach McAllister", "Zach Miner", "Zach Neal", "Zach Phillips",
"Zach Putnam", "Zach Stewart", "Zach Vincej", "Zach Walters",
"Zack Cozart", "Zack Godley", "Zack Greinke", "Zack Jones", "Zack Littell",
"Zack Weiss", "Zack Wheeler", "Zeke Spruill", "Zelous Wheeler",
"Zoilo Almonte"), class = "factor"), pitch_type = structure(c(7L,
7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L), .Label = c("",
"CH", "CU", "EP", "FA", "FC", "FF", "FO", "FS", "FT", "IN", "KC",
"KN", "null", "PO", "SC", "SI", "SL", "UN"), class = "factor"),
plate_x = c(-0.811, 0.4122, -0.8755, 0.5118, 1.8249, -0.9254,
0.6108, 1.0743, 0.8679, -0.1156, 0.1902, 0.5776, -0.3345,
0.93), plate_z = c(3.5851, 1.5006, 1.7496, 2.9315, 0.962,
1.5818, 1.7514, 1.5292, 1.7016, 1.3489, 4.5356, 2.6537, 4.1402,
1.717), Called_Strike = c(0L, 0L, 1L, 1L, 0L, 0L, 1L, 0L,
1L, 0L, 0L, 1L, 0L, 1L), Ball = c(1L, 1L, 0L, 0L, 1L, 1L,
0L, 1L, 0L, 1L, 1L, 0L, 1L, 0L), description = structure(c(1L,
1L, 3L, 3L, 1L, 1L, 3L, 1L, 3L, 1L, 1L, 3L, 1L, 3L), .Label = c("ball",
"blocked_ball", "called_strike", "foul", "foul_bunt", "foul_pitchout",
"foul_tip", "hit_by_pitch", "hit_into_play", "hit_into_play_no_out",
"hit_into_play_score", "intent_ball", "missed_bunt", "pitchout",
"pitchout_hit_into_play", "pitchout_hit_into_play_no_out",
"pitchout_hit_into_play_score", "swinging_pitchout", "swinging_strike",
"swinging_strike_blocked", "unknown_strike"), class = "factor")), row.names = c(5L,
6L, 8L, 9L, 11L, 15L, 16L, 21L, 23L, 26L, 28L, 30L, 36L, 38L), class = "data.frame")
OShdwIn <- -1.1
OShdwOut <- 1.1
IShdwIn <- -0.56
IShdwOut <- 0.56
topKzone <- 3.5
botKzone <- 1.6
inKzone <- -0.95
outKzone <- 0.95
OShdwTop <- 3.83
IShdwtop <- 3.38
IShdBot <- 1.8
OShdBot <- 1.17