#' @title Getting Player Predictions
#'
#' @description This function retrieves each player's predictions for my PremPredict competition.
#' @param url_value A character string for the URL on Dropbox of the csv file that stores these predictions.
#' @keywords import
#' @export
#' @examples
#' \dontrun{
#' get_player_data(url_value = "https://www.abcdef.com/abcdefg123.csv")
#' }
get_player_data <- function(url_value){
myConnection <- url(
paste0(url_value, "?raw=1")
)
data_early <- readr::read_csv(myConnection) %>%
dplyr::select(-Timestamp, -`If you want email updates on the competition, please provide your email address`) %>%
dplyr::arrange(`Who is making this prediction?`) %>%
t
data_rowname <- c("Club", row.names(data_early)[-1])
data_full <- cbind(data_rowname, data_early)
colnames(data_full) <- data_full[1,]
# I might need to augment the recode elements over the seasons
data_input <- data_full %>%
dplyr::as_tibble() %>%
dplyr::slice(-1) %>%
dplyr::mutate(Club = stringr::str_sub(Club, start = 30, end = -2)) %>%
dplyr::mutate_at(
.vars = dplyr::vars(-Club),
.funs = dplyr::funs(as.integer(stringr::str_extract(., "([0-9]+)")))
) %>%
dplyr::mutate(Club = dplyr::recode(
.x = Club,
`Bournemouth` = "AFC Bournemouth",
`Brighton and Hove Albion` = "Brighton",
`Cardiff City` = "Cardiff",
`Crystal Palace` = "C Palace",
`Huddersfield Town` = "Huddersfield",
`Leicester City` = "Leicester",
`Manchester City` = "Man City",
`Manchester United` = "Man Utd",
`Newcastle United` = "Newcastle",
`Norwich City` = "Norwich",
`Sheffield United` = "Sheff Utd",
`Tottenham Hotspur` = "Spurs",
`West Ham United` = "West Ham",
`Wolverhampton Wanderers` = "Wolves")
) %>%
dplyr::arrange(Club)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.