Last active
March 11, 2017 21:57
-
-
Save juanitobanca/275ce4cdab0c612e73914cfca3fe9cc2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
f_park_factors <- function( p_year, p_data, p_hist ) | |
{ | |
p_data %>% | |
filter( YEAR <= p_year & YEAR >= p_year - p_hist + 1 ) %>% | |
group_by( TEAM_ID, PARK_ID ) %>% | |
summarise( H_RS = sum( x = H_RS ) | |
, H_RA = sum( x = H_RA ) | |
, H_G = sum( x = H_G ) | |
, A_RS = sum( x = A_RS ) | |
, A_RA = sum( x = A_RA ) | |
, A_G = sum( x = A_G ) | |
, YEARS = n() | |
) %>% | |
mutate( YEAR = p_year | |
, PK_FACTOR = ((H_RS + H_RA)/H_G)/((A_RS + A_RA)/A_G) | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment