library(tidyverse)
library(readr) # Read in datasets.
options(scipen = 9999)
ffhistory <- read_csv(file = "C:/Users/chris/Documents/Datasets/FFL/ff_scores.csv",
show_col_types = FALSE)
ffhistory_inverse <- ffhistory
team_1 <- ffhistory$team_1
team_1_score <- ffhistory$team_1_score
team_2 <- ffhistory$team_2
team_2_score <- ffhistory$team_2_score
ffhistory_inverse$team_1 <- team_2
ffhistory_inverse$team_1_score <- team_2_score
ffhistory_inverse$team_2 <- team_1
ffhistory_inverse$team_2_score <- team_1_score
ffhistory_inverse$win <- ifelse(ffhistory_inverse$win == 0, 1, 0)
ffhistory_inverted <- rbind(ffhistory, ffhistory_inverse) %>%
arrange(date)
head(ffhistory_inverted[,1:9])
year | week | team_1 | team_1_score | team_2 | team_2_score | win | reg | playoffs |
---|---|---|---|---|---|---|---|---|
<dbl> | <chr> | <chr> | <dbl> | <chr> | <dbl> | <dbl> | <dbl> | <dbl> |
2014 | 01 | CHRIS | 119.68 | CARLEN | 126.34 | 0 | 1 | 0 |
2014 | 01 | ANDREW | 106.28 | KYLE | 145.94 | 0 | 1 | 0 |
2014 | 01 | STEVE | 103.46 | DREW | 101.92 | 1 | 1 | 0 |
2014 | 01 | MATT | 125.50 | NATHAN | 99.86 | 1 | 1 | 0 |
2014 | 01 | CARLEN | 126.34 | CHRIS | 119.68 | 1 | 1 | 0 |
2014 | 01 | KYLE | 145.94 | ANDREW | 106.28 | 1 | 1 | 0 |
write.csv(ffhistory_inverted,"C:\\Users\\chris\\Desktop\\ffscores_inverted.csv", row.names = FALSE)