Learn R Programming

fivethirtyeight (version 0.5.0)

nba_carmelo: The Complete History Of The NBA 2017-18 NBA Predictions

Description

The raw data behind the story "The Complete History Of The NBA" https://projects.fivethirtyeight.com/complete-history-of-the-nba/ and our "2017-18 NBA Predictions" https://projects.fivethirtyeight.com/2018-nba-predictions/

Usage

nba_carmelo

Arguments

Format

Because of R package size restrictions, only a preview of the first 10 rows of this dataset is included; to obtain the entire dataset (1871 to 2017 games) see Examples below. A data frame with 10 rows representing games and 20 variables:

date

Date

season

Season year, 1947-2018

neutral

TRUE if the game was played on neutral territory, FALSE if not

playoff

TRUE if the game was a playoff game, FALSE if not

team1

The name of one participating team

team2

The name of the other participating team

elo1_pre

Team 1's Elo rating before the game

elo2_pre

Team 2's Elo rating before the game

elo_prob1

Team 1's probability of winning based on Elo rating

elo_prob2

Team 2's probability of winning based on Elo rating

elo1_post

Team 1's Elo rating after the game

elo2_post

Team 2's Elo rating after the game

carmelo1_pre

Team 1's CARMELO rating before the game

carmelo2_pre

Team 2's CARMELO rating before the game

carmelo1_post

Team 1's CARMELO rating after the game

carmelo2_post

Team 2's CARMELO rating after the game

carmelo_prob1

Team 1's probability winning based on CARMELO rating

carmelo_prob2

Team 2's probability of winning based on CARMELO rating

score1

Points scored by Team 1

score2

Points scored by Team 2

Examples

Run this code
# NOT RUN {
# To obtain the entire dataset, run the following code:
library(dplyr)
library(tidyr)
library(readr)
library(janitor)
nba_carmelo <- read_csv("https://projects.fivethirtyeight.com/nba-model/nba_elo.csv") %>%
  clean_names() %>%
  mutate(
    team1 = as.factor(team1),
    team2 = as.factor(team2),
    playoff = ifelse(playoff == "t", TRUE, FALSE),
    playoff = ifelse(is.na(playoff), FALSE, TRUE),
    neutral = ifelse(neutral == 1, TRUE, FALSE)
  )
# }

Run the code above in your browser using DataLab