Skip to content

Commit

Permalink
add variable description
Browse files Browse the repository at this point in the history
  • Loading branch information
mrcaseb committed Oct 16, 2024
1 parent 627d6a6 commit 28db290
Show file tree
Hide file tree
Showing 8 changed files with 548 additions and 4 deletions.
11 changes: 11 additions & 0 deletions R/data_documentation.R
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,14 @@
#' stat_ids
#' }
"stat_ids"

#' NFL Stats Variables
#'
#' @docType data
#' @format A data frame explaining all variables returned by the function
#' [calculate_stats()].
#' @examples
#' \donttest{
#' nfl_stats_variables
#' }
"nfl_stats_variables"
36 changes: 36 additions & 0 deletions data-raw/nfl_stats_variables.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
s1 <- calculate_stats(2023, "season", "player")
s2 <- calculate_stats(2023, "week", "player")
s3 <- calculate_stats(2023, "season", "team")
s4 <- calculate_stats(2023, "week", "team")

n1 <- names(s1)
n2 <- names(s2)
n3 <- names(s3)
n4 <- names(s4)

setdiff(n1, n2)
setdiff(n2, n1)

setdiff(n1, n3)
setdiff(n3, n1)

# tibble::tibble(
# variable = c(n1, n2, n3, n4) %>% unique(),
# description = ""
# ) %>%
# jsonlite::write_json("data-raw/nfl_stats_variables.json", pretty = TRUE)

nfl_stats_variables <- jsonlite::fromJSON("data-raw/nfl_stats_variables.json")

usethis::use_data(nfl_stats_variables)

s_old_1 <- nflreadr::load_player_stats(2024, "offense")
s_old_2 <- nflreadr::load_player_stats(2024, "defense")
s_old_3 <- nflreadr::load_player_stats(2024, "kicking")
n_old_1 <- names(s_old_1)
n_old_2 <- names(s_old_2)
n_old_3 <- names(s_old_3)

setdiff(n2, n_old_1)
setdiff(n2, n_old_3)
setdiff(n_old_1, n2)
Loading

0 comments on commit 28db290

Please sign in to comment.