Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0d017b8

Browse files
authored
Merge pull request#4 from saiemgilani/teams_fix
Teams fix
2 parentse4f176b +7d49b9d commit0d017b8

34 files changed

+245
-163
lines changed

‎DESCRIPTION

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: wehoop
22
Title: Functions to Access Women's Basketball Play by Play Data
3-
Version: 0.9.0
3+
Version: 0.9.1
44
Authors@R: c(person('Saiem', 'Gilani', email = 'saiem.gilani@gmail.com',role = c('aut','cre')),
55
person('Geoff','Hutchinson', email = 'geoffery.hutchinson@gmail.com', role = c('aut')))
66
Description: The R package wehoop is for working with women's college and professional basketball data. A scraping and aggregating interface for ESPN's women's college basketball and WNBA statistics, [espn.com](https://espn.com). It provides users with the capability to access the API's game play-by-plays, box scores, standings and results to analyze the data for themselves.
@@ -15,6 +15,7 @@ Imports:
1515
furrr,
1616
future,
1717
glue,
18+
janitor,
1819
jsonlite,
1920
httr,
2021
magrittr,

‎NAMESPACE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ importFrom(dplyr,select)
3535
importFrom(dplyr,ungroup)
3636
importFrom(glue,glue)
3737
importFrom(httr,status_code)
38+
importFrom(janitor,clean_names)
3839
importFrom(jsonlite,fromJSON)
3940
importFrom(jsonlite,toJSON)
4041
importFrom(magrittr,"%>%")

‎NEWS.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
#**wehoop 0.9.1**
2+
3+
###**Clean names and team returns**
4+
- All functions have now been given the[```janitor::clean_names()```](https://rdrr.io/cran/janitor/man/clean_names.html) treatment
5+
-[```wehoop::espn_wbb_teams()](https://saiemgilani.github.io/wehoop/reference/espn_wbb_teams.html) has updated the returns to be more identity information related only
6+
-[```wehoop::espn_wnba_teams()](https://saiemgilani.github.io/wehoop/reference/espn_wnba_teams.html) to be more identity information related only
7+
- All tests were updated
8+
19
#**wehoop 0.9.0**
210

311
###**Loading capabilities added to the package**

‎R/espn_wbb_data.R

Lines changed: 48 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,8 @@
88
#' @importFrom dplyr filter select rename bind_cols bind_rows
99
#' @importFrom tidyr unnest unnest_wider everything
1010
#' @export
11-
#'
1211
#' @examples
13-
#'
14-
#' espn_wbb_game_all(game_id = 401276115)
15-
#'
12+
#' espn_wbb_game_all(game_id = 401276115)
1613

1714
espn_wbb_game_all<-function(game_id,verbose=FALSE){
1815
options(stringsAsFactors=FALSE)
@@ -108,6 +105,15 @@ espn_wbb_game_all <- function(game_id, verbose = FALSE){
108105

109106
player_box<-dplyr::bind_cols(stats_df,players_df) %>%
110107
dplyr::select(.data$athlete.displayName,.data$team.shortDisplayName,tidyr::everything())
108+
plays_df<-plays_df %>%
109+
janitor::clean_names()
110+
team_box_score<-team_box_score %>%
111+
janitor::clean_names()
112+
player_box<-player_box %>%
113+
janitor::clean_names() %>%
114+
dplyr::rename(
115+
fg3=.data$x3pt
116+
)
111117
},
112118
error=function(e) {
113119
if(verbose){
@@ -135,11 +141,8 @@ espn_wbb_game_all <- function(game_id, verbose = FALSE){
135141
#' @importFrom dplyr filter select rename bind_cols bind_rows
136142
#' @importFrom tidyr unnest unnest_wider everything
137143
#' @export
138-
#'
139144
#' @examples
140-
#'
141-
#' espn_wbb_pbp(game_id = 401276115)
142-
#'
145+
#' espn_wbb_pbp(game_id = 401276115)
143146
espn_wbb_pbp<-function(game_id,verbose=FALSE){
144147
options(stringsAsFactors=FALSE)
145148
options(scipen=999)
@@ -167,6 +170,8 @@ espn_wbb_pbp <- function(game_id, verbose = FALSE){
167170
names(aths)[1]<-c("play.id")
168171
plays_df<-dplyr::bind_cols(plays,aths) %>%
169172
select(-.data$athlete.id)
173+
plays_df<-plays_df %>%
174+
janitor::clean_names()
170175
},
171176
error=function(e) {
172177
if(verbose){
@@ -191,12 +196,8 @@ espn_wbb_pbp <- function(game_id, verbose = FALSE){
191196
#' @importFrom dplyr filter select rename bind_cols bind_rows
192197
#' @importFrom tidyr unnest unnest_wider everything
193198
#' @export
194-
#'
195199
#' @examples
196-
#'
197-
#'
198200
#' espn_wbb_team_box(game_id = 401276115)
199-
#'
200201
espn_wbb_team_box<-function(game_id,verbose=FALSE){
201202
options(stringsAsFactors=FALSE)
202203
options(scipen=999)
@@ -223,6 +224,8 @@ espn_wbb_team_box <- function(game_id, verbose = FALSE){
223224
tm<- c(teams_box_score_df[2,"team.shortDisplayName"],"Team",teams_box_score_df[1,"team.shortDisplayName"])
224225
names(tm)<- c("Home","label","Away")
225226
team_box_score=dplyr::bind_rows(tm,team_box_score)
227+
team_box_score<-team_box_score %>%
228+
janitor::clean_names()
226229
},
227230
error=function(e) {
228231
if(verbose) message(glue::glue("{Sys.time()}: Invalid arguments or no team box score data for {game_id} available!"))
@@ -245,11 +248,8 @@ espn_wbb_team_box <- function(game_id, verbose = FALSE){
245248
#' @importFrom dplyr filter select rename bind_cols bind_rows
246249
#' @importFrom tidyr unnest unnest_wider everything
247250
#' @export
248-
#'
249251
#' @examples
250-
#'
251252
#' espn_wbb_player_box(game_id = 401276115)
252-
#'
253253
espn_wbb_player_box<-function(game_id,verbose=FALSE){
254254
options(stringsAsFactors=FALSE)
255255
options(scipen=999)
@@ -286,6 +286,11 @@ espn_wbb_player_box <- function(game_id, verbose = FALSE){
286286

287287
player_box<-dplyr::bind_cols(stats_df,players_df) %>%
288288
dplyr::select(.data$athlete.displayName,.data$team.shortDisplayName,tidyr::everything())
289+
player_box<-player_box %>%
290+
janitor::clean_names() %>%
291+
dplyr::rename(
292+
fg3=.data$x3pt
293+
)
289294
},
290295
error=function(e) {
291296
if(verbose) message(glue::glue("{Sys.time()}: Invalid arguments or no player box score data for {game_id} available!"))
@@ -313,9 +318,7 @@ espn_wbb_player_box <- function(game_id, verbose = FALSE){
313318
#' @export
314319
#'
315320
#' @examples
316-
#'
317321
#' espn_wbb_teams()
318-
#'
319322

320323
espn_wbb_teams<-function(){
321324
options(stringsAsFactors=FALSE)
@@ -352,8 +355,24 @@ espn_wbb_teams <- function(){
352355
stats<-s %>% unnest_wider(.data$g)
353356

354357
records<-dplyr::bind_cols(records %>%dplyr::select(.data$summary),stats)
355-
leagues<-leagues %>%dplyr::select(-.data$record,-.data$links)
356-
teams<-dplyr::bind_cols(leagues,records)
358+
leagues<-leagues %>%dplyr::select(
359+
-.data$record,
360+
-.data$links,
361+
-.data$isActive,
362+
-.data$isAllStar,
363+
-.data$uid,
364+
-.data$slug)
365+
teams<-leagues %>%
366+
dplyr::rename(
367+
logo=.data$logos_href_1,
368+
logo_dark=.data$logos_href_2,
369+
mascot=.data$name,
370+
team=.data$location,
371+
team_id=.data$id,
372+
short_name=.data$shortDisplayName,
373+
alternate_color=.data$alternateColor,
374+
display_name=.data$displayName
375+
)
357376
},
358377
error=function(e) {
359378
message(glue::glue("{Sys.time()}: Invalid arguments or no teams data available!"))
@@ -382,7 +401,6 @@ espn_wbb_teams <- function(){
382401
#' @export
383402
#' @examples
384403
#' # Get schedule returns 1000 results, max allowable.
385-
#' # Must iterate through dates to get full year's schedule, as below:
386404
#' # Get schedule from date 2021-02-15, then next date and so on.
387405
#' espn_wbb_scoreboard (season = "20210215")
388406

@@ -485,12 +503,15 @@ espn_wbb_scoreboard <- function(season, verbose = FALSE){
485503
broadcast_market=list(1,"market"),
486504
broadcast_name=list(1,"names",1)
487505
) %>%
488-
dplyr::select(!where(is.list))
506+
dplyr::select(!where(is.list)) %>%
507+
janitor::clean_names()
489508
}else {
490-
schedule_out
509+
schedule_out %>%
510+
janitor::clean_names()
491511
}
492512
}else {
493-
wbb_data %>%dplyr::select(!where(is.list))
513+
wbb_data %>%dplyr::select(!where(is.list)) %>%
514+
janitor::clean_names()
494515
}
495516
},
496517
error=function(e) {
@@ -528,7 +549,8 @@ ncaa_wbb_NET_rankings <- function(){
528549
xml2::read_html() %>%
529550
rvest::html_nodes("table"))[[1]] %>%
530551
rvest::html_table(fill=TRUE) %>%
531-
dplyr::as_tibble()
552+
dplyr::as_tibble() %>%
553+
janitor::clean_names()
532554
},
533555
error=function(e) {
534556
message(glue::glue("{Sys.time()}: Invalid arguments or no NET rankings available!"))
@@ -584,7 +606,8 @@ espn_wbb_rankings <- function(){
584606
)
585607
ranks<-ranks %>%
586608
dplyr::select(-dplyr::any_of(drop_cols))
587-
ranks<-ranks %>%dplyr::arrange(.data$name,-.data$points)
609+
ranks<-ranks %>%dplyr::arrange(.data$name,-.data$points) %>%
610+
janitor::clean_names()
588611
return(ranks)
589612
}
590613

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp