Skip to content

Commit

Permalink
Merge pull request #3 from saiemgilani/styling
Browse files Browse the repository at this point in the history
Future, progressr, and database methods
  • Loading branch information
saiemgilani authored Apr 18, 2021
2 parents 26597da + dc6e4d3 commit 4a28de1
Show file tree
Hide file tree
Showing 201 changed files with 7,636 additions and 28,017 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,12 @@ jobs:

- name: Install package
run: R CMD INSTALL .

- name: Render README
run: Rscript -e 'rmarkdown::render("README.Rmd")'
- name: Commit results of README
run: |
git commit README.md -m 'Re-build README.Rmd' || echo "No changes to commit"
git push origin || echo "No changes to commit"
- name: Deploy package
run: |
git config --local user.email "[email protected]"
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
.RData
.Ruserdata
data-raw
docs
99 changes: 70 additions & 29 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,52 +1,93 @@
Package: cfbfastR
Title: Functions to Access College Football Play by Play Data
Version: 1.0.0
Authors@R: c(person('Saiem', 'Gilani', email = '[email protected]', role = c('cre', 'aut')),
person('Akshay', 'Easwaran', email = '[email protected]', role = c('aut')),
person('Jared','Lee', email = '[email protected]', role = c('aut')),
person('Eric','Hess', email = '[email protected]', role = c('aut')),
person('Michael','Egle', email = '[email protected]', role = c('ctb')),
person('Nate','Manzo', email = '[email protected]', role = c('ctb')),
person('Jason','DeLoach', email = '[email protected]', role = c('ctb')),
person('Tej', 'Seth', email = '[email protected]', role = c('ctb')),
person('Conor','McQuiston', email = '[email protected]', role = c('ctb')),
person('Tan', 'Ho', email = '[email protected]', role = c('ctb'))
)
Description: An R package for working with College Football Data. It is an R API wrapper around <https://collegefootballdata.com/> made available by the cfbfastR team. It provides users the capability to access a plethora of endpoints, and supplement that data with additional information (Expected Points Added/Win Probability added).
Version: 1.1.0
Authors@R:
c(person(given = "Saiem",
family = "Gilani",
role = c("cre", "aut"),
email = "[email protected]"),
person(given = "Akshay",
family = "Easwaran",
role = "aut",
email = "[email protected]"),
person(given = "Jared",
family = "Lee",
role = "aut",
email = "[email protected]"),
person(given = "Eric",
family = "Hess",
role = "aut",
email = "[email protected]"),
person(given = "Michael",
family = "Egle",
role = "ctb",
email = "[email protected]"),
person(given = "Nate",
family = "Manzo",
role = "ctb",
email = "[email protected]"),
person(given = "Jason",
family = "DeLoach",
role = "ctb",
email = "[email protected]"),
person(given = "Tej",
family = "Seth",
role = "ctb",
email = "[email protected]"),
person(given = "Conor",
family = "McQuiston",
role = "ctb",
email = "[email protected]"),
person(given = "Tan",
family = "Ho",
role = "ctb",
email = "[email protected]"))
Description: An R package for working with College Football Data. It is an
R API wrapper around <https://collegefootballdata.com/> made available
by the cfbfastR team. It provides users the capability to access a
plethora of endpoints, and supplement that data with additional
information (Expected Points Added/Win Probability added).
License: MIT + file LICENSE
URL: https://saiemgilani.github.io/cfbfastR/ (website), https://www.github.com/saiemgilani/cfbfastR (devel)
URL: https://saiemgilani.github.io/cfbfastR,
http://www.github.com/saiemgilani/cfbfastR
BugReports: http://www.github.com/saiemgilani/cfbfastR/issues
Encoding: UTF-8
Depends:
R (>= 3.5.0)
R (>= 3.5.0)
Imports:
assertthat,
attempt,
curl,
dplyr,
ggplot2,
furrr,
future,
glue,
httr,
janitor,
jsonlite,
magrittr,
mgcv (>= 1.8-33),
nnet,
purrr,
nnet,
progressr (>= 0.6.0),
purrr (>= 0.3.0),
rlang,
stringi,
stringr,
tibble,
tidyr,
utils
stringr (>= 1.3.0),
tibble (>= 3.0),
tidyr (>= 1.0.0),
usethis (>= 1.6.0),
xgboost (>= 1.1)
Suggests:
cli (>= 1.1.0),
crayon (>= 1.3.4),
curl,
DBI,
furrr,
future,
ggplot2,
ggrepel,
qs (>= 0.23.5),
rmarkdown,
RSQLite,
testthat,
ggrepel
stats,
testthat
Encoding: UTF-8
LazyData: true
RoxygenNote: 7.1.1
Roxygen: list(markdown = TRUE)

10 changes: 6 additions & 4 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,16 @@ export(epa_fg_probs)
export(espn_metrics_wp)
export(espn_ratings_fpi)
export(has_cfbd_key)
export(load_cfb_pbp)
export(penalty_detection)
export(prep_epa_df_after)
export(update_cfb_db)
export(wpa_calcs_naive)
import(dplyr)
import(purrr)
import(stringr)
import(tidyr)
importFrom(assertthat,assert_that)
importFrom(attempt,stop_if_all)
importFrom(attempt,stop_if_any)
importFrom(attempt,stop_if_not)
importFrom(curl,has_internet)
importFrom(dplyr,arrange)
importFrom(dplyr,as_tibble)
importFrom(dplyr,between)
Expand All @@ -91,6 +89,7 @@ importFrom(httr,RETRY)
importFrom(httr,status_code)
importFrom(janitor,clean_names)
importFrom(jsonlite,fromJSON)
importFrom(magrittr,"%>%")
importFrom(mgcv,bam)
importFrom(mgcv,predict.bam)
importFrom(nnet,multinom)
Expand Down Expand Up @@ -120,3 +119,6 @@ importFrom(utils,URLdecode)
importFrom(utils,URLencode)
importFrom(utils,data)
importFrom(utils,globalVariables)
importFrom(utils,installed.packages)
importFrom(utils,packageDescription)
importFrom(utils,packageVersion)
24 changes: 19 additions & 5 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,36 @@
# cfbfastR 1.0.0
# cfbfastR

### **v1.1.0**
#### **Add loading from Data Repository functionality**

* Added [```load_cfb_pbp()```](https://saiemgilani.github.io/cfbfastR/reference/load_cfb_pbp.html) and [```update_cfb_db()```](https://saiemgilani.github.io/cfbfastR/reference/update_cfb_db.html) functions. Pretty much cherry-picking the `nflfastR` methodology of loading data from the [`cfbfastR-data`](https://github.com/saiemgilani/cfbfastR-data/) repository.

#### **Add support for parallel processing and progress updates**

* Added [```furrr```](https://furrr.futureverse.org/index.html), [```future```](https://future.futureverse.org/), and [```progressr```](https://progressr.futureverse.org/) dependencies to the package to allow for parallel processing of the play-by-play data with progress updates if desired.

### **v1.0.0**

#### Function Naming Convention Change
#### **Function Naming Convention Change**

* All functions sourced from the College Football Data API will start with `cfbd_` as opposed to `cfb_` (as in cfbscrapR).
* All functions sourced from the College Football Data API will start with `cfbd_` as opposed to `cfb_` (as in cfbscrapR). One additional `cfbd_` function has been added that corresponds to the result when [```cfbd_pbp_data()```](https://saiemgilani.github.io/cfbfastR/reference/cfbd_pbp_data.html) has the parameter `epa_wpa=FALSE`. It has now been separated into its own function for clarity [```cfbd_plays()```](https://saiemgilani.github.io/cfbfastR/reference/cfbd_play.html). The parameter and functionality still exists in [```cfbd_pbp_data()```](https://saiemgilani.github.io/cfbfastR/reference/cfbd_pbp_data.html) but we expect this function will still exist but made obsolete in favor of a function more closely matching `nflfastR`'s naming conventions.

* Similarly, data and metrics sourced from ESPN will begin with `espn_` as opposed to `cfb_`. In particular, the two functions are now [```espn_ratings_fpi()```](https://saiemgilani.github.io/cfbfastR/reference/espn_ratings.html) and [```espn_metrics_wp()```](https://saiemgilani.github.io/cfbfastR/reference/espn_metrics.html)

* Data generated from any of the ```cfbfastR``` methods will use `cfb_`

#### College Football Data API Keys
#### **College Football Data API Keys**

The [CollegeFootballData API](https://collegefootballdata.com/) now requires an API key, here's a quick run-down:

* To get an API key, follow the directions here: [College Football Data Key Registration.](https://collegefootballdata.com/key)

* Using the key: At the beginning of every session or within an R environment, save your API key as the environment variable `CFBD_API_KEY` using a command like the following.
* Using the key: You can save the key for consistent usage by adding `CFBD_API_KEY=XXXX-YOUR-API-KEY-HERE-XXXXX` to your .REnviron file (easily accessed via [**`usethis::edit_r_environ()`**](https://usethis.r-lib.org/reference/edit.html)). Run [**`usethis::edit_r_environ()`**](https://usethis.r-lib.org/reference/edit.html) and THEN paste the following in the new script that pops up (with**out** quotations)
```r
CFBD_API_KEY = XXXX-YOUR-API-KEY-HERE-XXXXX
```

* For less consistent usage: At the beginning of every session or within an R environment, save your API key as the environment variable `CFBD_API_KEY` (with quotations) using a command like the following.

```{r}
Sys.setenv(CFBD_API_KEY = "XXXX-YOUR-API-KEY-HERE-XXXXX")
Expand Down
25 changes: 19 additions & 6 deletions R/cfbd_api_key.R
Original file line number Diff line number Diff line change
@@ -1,23 +1,36 @@
#' CFBD API Key Registration
#' @description Save your API Key as a system environment variable `CFBD_API_KEY`
#' @details To get access to an API key, follow the instructions at [https://collegefootballdata.com/key](https://collegefootballdata.com/key "Key Registration")
#'
#' @details To get access to an API key, follow the instructions at [https://collegefootballdata.com/key](https://collegefootballdata.com/key "Key Registration")\cr
#' \cr
#' **Using the key:** \cr
#'
#' You can save the key for consistent usage by adding \cr
#' `CFBD_API_KEY=XXXX-YOUR-API-KEY-HERE-XXXXX` \cr
#' to your .REnviron file (easily accessed via [**`usethis::edit_r_environ()`**](https://usethis.r-lib.org/reference/edit.html)).\cr
#' \cr
#' Run [**`usethis::edit_r_environ()`**](https://usethis.r-lib.org/reference/edit.html) and THEN paste the following in the new script that pops up (with**out** quotations)\cr
#' ```r
#' CFBD_API_KEY = XXXX-YOUR-API-KEY-HERE-XXXXX
#' ```
#' For less consistent usage:\cr
#' At the beginning of every session or within an R environment, save your API key as the environment variable `CFBD_API_KEY` (with quotations) using a command like the following.\cr
#' ```{r}
#' Sys.setenv(CFBD_API_KEY = "XXXX-YOUR-API-KEY-HERE-XXXXX")
#' ```
#' @name register_cfbd
NULL
#' @rdname register_cfbd
#' @export
cfbd_key <- function () {

cfbd_key <- function() {
key <- Sys.getenv("CFBD_API_KEY")

if (key == "") {
return(NA_character_)
} else {
return(key)
}

}

#' @rdname register_cfbd
#' @export
has_cfbd_key <- function () !is.na(cfbd_key())
has_cfbd_key <- function() !is.na(cfbd_key())
Loading

0 comments on commit 4a28de1

Please sign in to comment.