R/include_subgames.R

Defines functions get_subset_and_subgames

Documented in get_subset_and_subgames

#' Get subset and subgames realted to game type filtering
#' @param data tibble obtained from `read_and_prep_data`
#' @param ... filter options
#' @return subset of data with GameType == game_type and the associated doubles and triples included
get_subset_and_subgames <- function(data, ...) {
  
  df1 <- data %>% 
    dplyr::filter(...)
  
  sub_bets <- df1 %>% 
    dplyr::pull(Bet) %>% 
    paste0(collapse = "|")
  
  df2 <- data %>% 
    dplyr::filter(grepl(sub_bets, Bet))
  
  return(df2)
  
}
kristian-bak/betting documentation built on Oct. 24, 2022, 1:35 p.m.