R/get_latest_EPL_table.R

Defines functions get_latest_EPL_table

Documented in get_latest_EPL_table

#' @title Getting the Latest Standings in the Premier League
#'
#' @description This function gets the latest standings in the Premier League.
#' @param use_saved_data Whether to use a saved data frame. Default is FALSE.
#' @param data_file An rds file containing a data frame that is created by the get_player_data function.
#' @keywords import
#' @export
#' @examples
#' \dontrun{
#' get_latest_EPL_table()
#' }

get_latest_EPL_table <- function(use_saved_data = FALSE, data_file){

  if(use_saved_data != TRUE){

    xml2::read_html("http://www.theguardian.com/football/premierleague/table") %>%
      rvest::html_nodes(".table--striped") %>%
      .[[1]] %>%
      rvest::html_table()

  } else {

    readr::read_rds(data_file)

  }

}
p0bs/premPredictor documentation built on April 23, 2020, 2 p.m.