Skip to content

Commit

Permalink
try({}) in examples
Browse files Browse the repository at this point in the history
  • Loading branch information
saiemgilani committed Jan 15, 2024
1 parent 4c40362 commit edaf74e
Show file tree
Hide file tree
Showing 40 changed files with 114 additions and 85 deletions.
2 changes: 1 addition & 1 deletion R/fg_milb_pitcher_game_logs.R
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
#' @importFrom tidyr separate
#' @export
#' @examples \donttest{
#' fg_milb_pitcher_game_logs(playerid = "sa3020682", year=2023)
#' try(fg_milb_pitcher_game_logs(playerid = "sa3020682", year=2023))
#' }

fg_milb_pitcher_game_logs <- function(playerid, year) {
Expand Down
2 changes: 1 addition & 1 deletion R/fg_pitcher_leaders.R
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@
#' @import rvest
#' @export
#' @examples \donttest{
#' fg_pitcher_leaders(startseason = 2023, endseason = 2023)
#' try(fg_pitcher_leaders(startseason = 2023, endseason = 2023))
#' }
fg_pitcher_leaders <- function(
age = "",
Expand Down
2 changes: 1 addition & 1 deletion R/fg_team_fielder.R
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
#' @import rvest
#' @export
#' @examples \donttest{
#' fg_team_fielder(startseason = 2023, endseason = 2023, qual = 150)
#' try(fg_team_fielder(startseason = 2023, endseason = 2023, qual = 150))
#' }

fg_team_fielder <- function(
Expand Down
2 changes: 1 addition & 1 deletion R/fg_team_pitcher.R
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@
#' @import rvest
#' @export
#' @examples \donttest{
#' fg_team_pitcher(startseason = 2015, endseason = 2015, qual = 150)
#' try(fg_team_pitcher(startseason = 2015, endseason = 2015, qual = 150))
#' }

fg_team_pitcher <- function(
Expand Down
2 changes: 1 addition & 1 deletion R/load_ncaa_baseball_pbp.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#' @return Returns a tibble
#' @export
#' @examples \donttest{
#' load_ncaa_baseball_pbp(seasons = 2021)
#' try(load_ncaa_baseball_pbp(seasons = 2021))
#' }
load_ncaa_baseball_pbp <- function(seasons = most_recent_ncaa_baseball_season(), ...,
dbConnection = NULL, tablename = NULL) {
Expand Down
6 changes: 3 additions & 3 deletions R/load_ncaa_baseball_schedule.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
#' @param tablename The name of the schedule data table within the database
#' @return Returns a tibble
#' @export
#' @examples
#' load_ncaa_baseball_schedule(seasons = 2022)
#'
#' @examples \donttest{
#' try(load_ncaa_baseball_schedule(seasons = 2022))
#' }
load_ncaa_baseball_schedule <- function(seasons = most_recent_ncaa_baseball_season(), ...,
dbConnection = NULL, tablename = NULL) {
old <- options(list(stringsAsFactors = FALSE, scipen = 999))
Expand Down
6 changes: 3 additions & 3 deletions R/load_ncaa_baseball_season_ids.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
#' @param tablename The name of the data table within the database
#' @return Returns a tibble
#' @export
#' @examples
#' load_ncaa_baseball_season_ids()
#'
#' @examples \donttest{
#' try(load_ncaa_baseball_season_ids())
#' }
load_ncaa_baseball_season_ids <- function(...,
dbConnection = NULL, tablename = NULL) {
old <- options(list(stringsAsFactors = FALSE, scipen = 999))
Expand Down
6 changes: 3 additions & 3 deletions R/load_ncaa_baseball_teams.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
#' @param tablename The name of the data table within the database
#' @return Returns a tibble
#' @export
#' @examples
#' load_ncaa_baseball_teams()
#'
#' @examples \donttest{
#' try(load_ncaa_baseball_teams())
#' }
load_ncaa_baseball_teams <- function(...,
dbConnection = NULL, tablename = NULL) {
old <- options(list(stringsAsFactors = FALSE, scipen = 999))
Expand Down
6 changes: 4 additions & 2 deletions R/metrics_fip_plus.R
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,10 @@
#' @import rvest
#' @export
#' @examples \donttest{
#' df <- bref_daily_pitcher("2015-04-05", "2015-04-30")
#' try(fip_plus(df))
#' try({
#' df <- bref_daily_pitcher("2015-04-05", "2015-04-30")
#' fip_plus(df)
#' })
#' }

fip_plus <- function(df) {
Expand Down
11 changes: 6 additions & 5 deletions R/metrics_linear_weights_savant.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@
#'
#' @export
#' @examples \donttest{
#' df <- statcast_search(start_date = "2016-04-06", end_date = "2016-04-15",
#' playerid = 621043, player_type = 'batter')
#' df <- run_expectancy_code(df, level = "plate appearances")
#' try(linear_weights_savant(df, level = "plate appearance"))
#' try({
#' df <- statcast_search(start_date = "2016-04-06", end_date = "2016-04-15",
#' playerid = 621043, player_type = 'batter')
#' df <- run_expectancy_code(df, level = "plate appearances")
#' linear_weights_savant(df, level = "plate appearance")
#' })
#' }


linear_weights_savant <- function (df, level = "plate appearance"){

if(level == "plate appearance") {
Expand Down
8 changes: 5 additions & 3 deletions R/metrics_run_expectancy_code.R
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,11 @@
#' @importFrom rlang .data
#' @export
#' @examples \donttest{
#' df <- statcast_search(start_date = "2016-04-06", end_date = "2016-04-15",
#' playerid = 621043, player_type = 'batter')
#' try(run_expectancy_code(df, level = "plate appearances"))
#' try({
#' df <- statcast_search(start_date = "2016-04-06", end_date = "2016-04-15",
#' playerid = 621043, player_type = 'batter')
#' run_expectancy_code(df, level = "plate appearances")
#' })
#' }

run_expectancy_code <- function(df, level = "plate appearance"){
Expand Down
3 changes: 2 additions & 1 deletion R/metrics_team_consistency.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@
#' @import rvest
#' @export
#' @details
#' ```r
#' try(team_consistency(year=2021))
#'
#' ```

team_consistency <- function(year) {

Expand Down
6 changes: 4 additions & 2 deletions R/metrics_woba_plus.R
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,10 @@
#' @import rvest
#' @export
#' @examples \donttest{
#' df <- bref_daily_batter("2015-08-01", "2015-10-03")
#' try(woba_plus(df))
#' try({
#' df <- bref_daily_batter("2015-08-01", "2015-10-03")
#' woba_plus(df)
#' })
#' }
woba_plus <- function(df) {

Expand Down
5 changes: 0 additions & 5 deletions R/mlb_award.R
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,4 @@
#' ```
#'
#'
#'
#'
#'
#'
#'
NULL
2 changes: 1 addition & 1 deletion R/mlb_player_status_codes.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#' |player_status_description |character |
#' @export
#' @examples \donttest{
#' mlb_player_status_codes()
#' try(mlb_player_status_codes())
#' }
mlb_player_status_codes <- function(){

Expand Down
2 changes: 1 addition & 1 deletion R/mlb_seasons.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#' @export
#'
#' @examples \donttest{
#' mlb_seasons(sport_id = 1)
#' try(mlb_seasons(sport_id = 1))
#' }

mlb_seasons <- function(sport_id = 1,
Expand Down
2 changes: 1 addition & 1 deletion R/mlb_seasons_all.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
#' @export
#'
#' @examples \donttest{
#' mlb_seasons_all(sport_id = 1)
#' try(mlb_seasons_all(sport_id = 1))
#' }

mlb_seasons_all <- function(sport_id = 1,
Expand Down
20 changes: 12 additions & 8 deletions R/sc_statcast_search.R
Original file line number Diff line number Diff line change
Expand Up @@ -411,10 +411,12 @@ statcast_search.default <- function(start_date = Sys.Date() - 1, end_date = Sys.
#' @export
#' @examples
#' \donttest{
#' correa <- statcast_search_batters(start_date = "2016-04-06",
#' end_date = "2016-04-15", batterid = 621043)
#' daily <- statcast_search_batters(start_date = "2016-04-06",
#' end_date = "2016-04-06", batterid = NULL)
#' try({
#' correa <- statcast_search_batters(start_date = "2016-04-06",
#' end_date = "2016-04-15", batterid = 621043)
#' daily <- statcast_search_batters(start_date = "2016-04-06",
#' end_date = "2016-04-06", batterid = NULL)
#' })
#' }

statcast_search_batters <- function(start_date, end_date, batterid = NULL, ...) {
Expand Down Expand Up @@ -525,10 +527,12 @@ statcast_search_batters <- function(start_date, end_date, batterid = NULL, ...)
#' @export
#' @examples
#' \donttest{
#' x <- statcast_search_pitchers(start_date = "2016-04-06",
#' end_date = "2016-04-15", pitcherid = 592789)
#' daily <- statcast_search_pitchers(start_date = "2016-04-06",
#' end_date = "2016-04-06", pitcherid = NULL)
#' try({
#' x <- statcast_search_pitchers(start_date = "2016-04-06",
#' end_date = "2016-04-15", pitcherid = 592789)
#' daily <- statcast_search_pitchers(start_date = "2016-04-06",
#' end_date = "2016-04-06", pitcherid = NULL)
#' })
#' }

statcast_search_pitchers <- function(start_date, end_date, pitcherid = NULL, ...) {
Expand Down
8 changes: 5 additions & 3 deletions R/sch_label_statcast_imputed_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,11 @@
#' @export
#' @examples
#' \donttest{
#' statcast_df <- statcast_search("2017-05-01", "2017-05-02")
#' sc_df <- label_statcast_imputed_data(statcast_df)
#' mean(sc_df$imputed)
#' try({
#' statcast_df <- statcast_search("2017-05-01", "2017-05-02")
#' sc_df <- label_statcast_imputed_data(statcast_df)
#' mean(sc_df$imputed)
#' })
#' }
label_statcast_imputed_data <- function(statcast_df, impute_file = NULL,
inverse_precision = 10000) {
Expand Down
2 changes: 1 addition & 1 deletion R/sch_statline_from_statcast.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#' @export
#' @details
#' ```r
#' statline_from_statcast(df, base = "contact")
#' statline_from_statcast(df, base = "contact")
#' ```

statline_from_statcast <- function(df, base = "pa") {
Expand Down
2 changes: 2 additions & 0 deletions cran-comments.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ This is a minor release that primarily focused on parameter changes to the `fg_*
- `fg_batter_leaders()`
- `fg_pitcher_leaders()`
- `fg_fielder_leaders()`

Examples made more robust to adhere to graceful failing policies per CRAN review. Vignettes removed from package for simplicity.



Expand Down
2 changes: 1 addition & 1 deletion man/fg_milb_pitcher_game_logs.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/fg_pitcher_leaders.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/fg_team_fielder.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/fg_team_pitcher.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions man/fip_plus.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions man/label_statcast_imputed_data.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 6 additions & 4 deletions man/linear_weights_savant.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/load_ncaa_baseball_pbp.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions man/load_ncaa_baseball_schedule.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions man/load_ncaa_baseball_season_ids.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions man/load_ncaa_baseball_teams.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/mlb_player_status_codes.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/mlb_seasons.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/mlb_seasons_all.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit edaf74e

Please sign in to comment.