Learn R Programming

fastR2 (version 0.2.0)

NCAAbb: NCAA Division I Basketball Results

Description

Results of NCAA basketball games

Arguments

Format

Nine variables describing NCAA Division I basketball games.

  • date date on which game was played

  • away visiting team

  • ascore visiting team's score

  • home home team

  • hscore home team's score

  • notes code indicting games played at neutral sites (n or N) or in tournaments (T)

  • location where game was played

  • season a character indicating which season the game belonged to

  • postseason a logical indicating whether the game is a postseason game

Examples

Run this code
# NOT RUN {
data(NCAAbb)
# select one year and add some additional variables to the data frame
NCAA2010 <-
  NCAAbb %>% 
  filter(season == "2009-10") %>%
  mutate(
    dscore = hscore - ascore,
    homeTeamWon = dscore > 0,
    numHomeTeamWon <- -1 + 2 * as.numeric(homeTeamWon),
    winner = ifelse(homeTeamWon, home, away),
    loser  = ifelse(homeTeamWon, away, home),
    wscore = ifelse(homeTeamWon, hscore, ascore),
    lscore = ifelse(homeTeamWon, ascore, hscore)
  )
NCAA2010 %>% select(date, winner, loser, wscore, lscore, dscore, homeTeamWon) %>% head()
# }

Run the code above in your browser using DataLab