Skip to content

Commit

Permalink
Merge pull request #96 from sportsdataverse/AE/handle-NaN-in-lines
Browse files Browse the repository at this point in the history
  • Loading branch information
akeaswaran committed Feb 1, 2024
2 parents 3fb0e6f + 60b1fb2 commit a6689e0
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion R/cfbd_betting.R
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
#' @importFrom purrr map_if
#' @importFrom dplyr filter as_tibble rename
#' @importFrom tidyr unnest
#' @importFrom stringr str_replace_all
#' @export
#' @examples
#' \donttest{
Expand Down Expand Up @@ -136,10 +137,27 @@ cfbd_betting_lines <- function(game_id = NULL,
# Get the content and return it as data.frame
df <- res %>%
httr::content(as = "text", encoding = "UTF-8") %>%
stringr::str_replace_all("NaN", 'null') %>%
jsonlite::fromJSON(flatten = TRUE) %>%
purrr::map_if(is.data.frame, list) %>%
dplyr::as_tibble() %>%
tidyr::unnest("lines")
tidyr::unnest("lines") %>%
dplyr::mutate(
overUnder = dplyr::case_when(
.data$overUnder == "null" ~ NA_character_,
.default = .data$overUnder
),
spread = dplyr::case_when(
.data$spread == "null" ~ NA_character_,
.default = .data$spread
),
formattedSpread = dplyr::case_when(
is.na(.data$spread) ~ NA_character_,
.default = .data$formattedSpread
)
)



if (!is.null(line_provider)) {
if (is.list(df) & length(df) == 0) {
Expand Down

0 comments on commit a6689e0

Please sign in to comment.