#' Get nba data from ballr package. Mixed data (adv + per game)
#'
#' @param season The year of the season
#'
#' @return The data frame of the \code{season}
#' @export
#' @importFrom ballr NBAPerGameAdvStatistics NBAPerGameStatistics
#' @import dplyr
#'
#' @examples
#' get_data_from_ball_r(season=2018)
#' get_data_from_ball_r(season=1994)
get_data_from_ball_r <- function(season=2018) {
#
drop_col_adv <- c("x", "x_2", "link")
drop_col_pg <- c("link")
new_colnames <- c("rk", "player", "pos", "age", "tm", "g", "gs", "mppg", "fg",
"fga", "fgpercent", "x3p", "x3pa", "x3ppercent", "x2p", "x2pa", "x2ppercent",
"efgpercent", "ft", "fta", "ftpercent", "orb", "drb", "trb", "ast", "stl",
"blk", "tov", "pf", "pts", "link")
df_1 <- NBAPerGameAdvStatistics(season)
df_2 <- NBAPerGameStatistics(season)
colnames(df_2) <- new_colnames
df_1 <-
df_1 %>%
select(-one_of(drop_col_adv))
df_2 <-
df_2 %>%
select(-one_of(drop_col_pg))
df_0 <-
full_join(df_1, df_2, by = c("rk", "player", "pos", "age", "tm", "g"))
df_0
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.