R/convert_time.R

#' Function To Convert Event Times
#'
#' This function converts match event times to numeric allowing for added time but not extra time
#' @keywords convert event time
#' @importFrom rvest %>%
#' @export
#' @examples
#' convert_time()

convert_time <- function(eventTime){
  if(grepl("90'?\\+\\d+'?",eventTime)){
    return(gsub("'","",eventTime) %>% gsub("90\\+","",.) %>% as.numeric() + 90)
  }else if(grepl("45'?\\+\\d+'?",eventTime)){
    return(45)
  }else if(gsub("'?(\\+\\d+)?'?","",eventTime) %>% as.numeric() > 90){
    return(NA)
  }else{
    return(gsub("'","",eventTime) %>% as.numeric())
  }
}
JimmyClowes/wc2018SweepstakeStats documentation built on May 30, 2019, 4:05 a.m.