Skip to content

Commit

Permalink
clean up spread and formattedSpread
Browse files Browse the repository at this point in the history
Signed-off-by: Akshay Easwaran <[email protected]>
  • Loading branch information
akeaswaran authored Jan 7, 2024
1 parent 09ef280 commit 20e06c1
Showing 1 changed file with 20 additions and 12 deletions.
32 changes: 20 additions & 12 deletions R/cfbd_betting.R
Original file line number Diff line number Diff line change
Expand Up @@ -136,18 +136,26 @@ 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") %>%
dplyr::mutate(
overUnder = dplyr::case_when(
overUnder == "null" ~ NA_character_,
.default = overUnder
)
)
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") %>%
dplyr::mutate(
overUnder = dplyr::case_when(
overUnder == "null" ~ NA_character_,
.default = overUnder
),
spread = dplyr::case_when(
spread == "null" ~ NA_character_,
.default = spread
),
formattedSpread = dplyr::case_when(
is.na(spread) ~ NA_character_,
.default = formattedSpread
)
)



Expand Down

0 comments on commit 20e06c1

Please sign in to comment.