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
playername_lookup <- function(string=NULL) { | |
if (!exists("chadwick_player_lu_table")) { | |
print("Be patient, this may take a few seconds...") | |
print("Data courtesy of the Chadwick Bureau Register (https://github.com/chadwickbureau/register)") | |
id <- string | |
url <- "https://raw.githubusercontent.com/chadwickbureau/register/master/data/people.csv" | |
chadwick_player_lu_table <- read.csv(url) | |
assign("chadwick_player_lu_table", chadwick_player_lu_table, envir = .GlobalEnv) | |
x <- chadwick_player_lu_table %>% | |
filter(key_mlbam == id) %>% | |
select(name_first, name_last) | |
paste(as.character(x$name_first), as.character(x$name_last)) | |
} | |
else { | |
id <- string | |
x <- chadwick_player_lu_table %>% | |
filter(key_mlbam == id) %>% | |
select(name_first, name_last) | |
paste(as.character(x$name_first), as.character(x$name_last)) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment