TPD-InternationalFootballRe.../.Rhistory

280 lines
7.1 KiB
R
Raw Normal View History

2019-05-14 22:41:05 +02:00
shiny::runApp()
runApp()
# Load data
football_data <- read.csv("results.csv")
head(football_data)
football_data <- as_tibble(read.csv("results.csv"))
library(dplyr)
football_data <- as_tibble(read.csv("results.csv"))
football_data %>% select(2)
football_data %>% select("home_team")
football_data %>% select("home_team") %>% unique()
runApp()
runApp()
runApp()
runApp()
runApp()
runApp()
runApp()
shiny::runApp()
runApp(display.mode = "showcase")
runApp(display.mode = "showcase")
runApp()
get_matches_list <- function(home_team, away_team) {
matches <- football_data %>%
select(1:5) %>%
filter("home_team" == home_team
& "away_team" == away_team)
return(matches)
}
get_matches_list("Scotland", "England")
head(get_matches_list("Scotland", "England"))
test <- get_matches_list("Scotland", "England")
test <- get_matches_list("Poland", "England")
test
football_data %>% filter("home_team" == "England")
football_data %>% filter(1 == "England")
football_data %>% filter(2 == "England")
matches <- football_data %>%
select(1:5) %>%
filter("home_team" %in% c(first_team, second_team)
& "away_team" %>% c(first_team, second_team))
matches <- football_data %>%
select(1:5) %>%
filter("home_team" %in% c("England")
)
football_data %>% filter(str_detect("home_team", "England")
)
library(stringr)
football_data %>% filter(str_detect("home_team", "England")_
football_data %>% filter(str_detect("home_team", "England"))
football_data %>% filter(str_detect(2, "England"))
football_data %>% filter(home_team == "England")
runApp()
runApp()
football_data_ext <- football_data %>%
select(2:4)
head(football_data_ext)
football_data_ext <- football_data %>%
select(2:6)
head(football_data_ext)
head(football_data)
football_data["home_team"]
get_winner_name <- function(match_row) {
if(match_row["home_score"] > match_row["away_score"]) {
return(match_row["home_team"])
}
else if(match_row["home_score"] < match_row["away_score"]) {
return(match_row["away_team"])
}
else {
return("Draw")
}
}
get_winner_name(football_data[0])
head(football_data)
get_winner_name(football_data[1])
football_data[1]
football_data[, 1]
top_n(football_data, 1)
football_data %>% slice(1)
football_data %>% slice(1) %>% get_winner_name()
football_data %>% select(2:5) %>% get_winner_name()
football_data %>% select(2:5)
football_data %>% select(2:5) %>% mutate(get_winner_name())
football_data %>% select(2:5) %>% mutate(get_winner_name(.))
football_data %>% select(2:5) %>% mutate(result = get_winner_name(.))
football_data %>% select(2:5) %>% rowwise() %>% mutate(result = get_winner_name(.))
warnings()
football_data %>% select(2:5) %>% rowwise() %>% mutate(result = get_winner_name())
football_data %>%
select(2:5) %>% mutate(get_winner_name(home_score, away_score, home_team, away_team))
get_winner_name <- function(home_score, away_score, home_team, away_team) {
if(home_score > away_score) {
return(home_team)
}
else if(home_score < away_score) {
return(away_team)
}
else {
return("Draw")
}
}
football_data %>%
select(2:5) %>% mutate(get_winner_name(home_score, away_score, home_team, away_team))
football_data %>%
select(2:5) %>% mutate(winner = get_winner_name(home_score, away_score, home_team, away_team))
football_data %>% slice(2)
football_data %>% slice(2) %>% get_winner_name()
get_winner_name <- function(match_row) {
if(match_row["home_score"] > match_row["away_score"]) {
return(match_row["home_team"])
}
else if(match_row["home_score"] < match_row["away_score"]) {
return(match_row["away_team"])
}
else {
return("Draw")
}
}
get_winner_name <- function(match_row) {
if(match_row["home_score"] > match_row["away_score"]) {
return(match_row["home_team"])
}
else if(match_row["home_score"] < match_row["away_score"]) {
return(match_row["away_team"])
}
else {
return("Draw")
}
}
football_data %>% slice(2) %>% get_winner_name()
football_data %>% get_winner_name()
football_data %>% rowwise() %>% get_winner_name()
football_data %>% apply(get_winner_name())
football_data %>% apply(., get_winner_name())
football_data %>% apply(., ,get_winner_name())
football_data %>% apply(., ,get_winner_name)
football_data %>% apply(., 1, get_winner_name)
football_data %>% mutate(winner = apply(., 1, get_winner_name))
runApp()
runApp()
runApp()
runApp()
runApp()
runApp()
runApp()
runApp()
runApp()
runApp()
runApp()
runApp()
runApp()
runApp()
runApp()
runApp()
runApp()
runApp()
2019-05-15 00:35:53 +02:00
shiny::runApp()
runApp()
install.packages("dt")
install.packages("DT")
install.packages(c("DT", "shiny"))
install.packages(c("DT", "shiny"))
shiny::runApp()
runApp()
runApp()
runApp()
exit()
runApp()
runApp()
runApp()
runApp()
runApp()
runApp()
runApp()
runApp()
# Functions
get_matches_list <- function(first_team, second_team) {
matches <- football_data %>%
select(1:9) %>%
filter(home_team %in% c(first_team, second_team)
& away_team %in% c(first_team, second_team))
return(matches)
}
runApp()
runApp()
runApp()
runApp()
runApp()
runApp()
runApp()
runApp()
View(football_data_ext)
getBalance <- function(data, home_team, away_team) {
balance <- data %>%
group_by(., "winner") %>%
summarise(n = n())
return(balance)
}
test <- getBalance(football_data_ext, "England", "Scotland")
test
head(test)
balance <- football_data_ext %>% group_by(., "winner")
View(balance)
balance <- football_data_ext %>% aggregate(,. by="winner")
balance <- football_data_ext %>% aggregate(., by="winner")
balance <- football_data_ext %>% aggregate(., by="winner", FUN = sum())
balance <- football_data_ext %>% aggregate(., by="winner", FUN = sum
)
balance <- football_data_ext %>% aggregate(., by=list(.$winner), FUN = sum)
balance <- football_data_ext %>% aggregate(., by=list(as.numeric(.$winner)), FUN = sum)
View(balance)
balance <- football_data_ext %>% group_by(., .$winner)
View(balance)
balance <- football_data_ext %>% group_by(.$winner)
View(balance)
balance <- football_data_ext %>% group_by(winner)
View(balance)
balance <- football_data_ext %>% count(winner)
View(balance)
getBalance <- function(data, home_team, away_team) {
balance <- data %>%
count(winner, sort = TRUE)
return(balance)
}
View(test)
test <- get_matches_list("England", "Scotland")
View(test)
getMatchesList <- function(first_team, second_team) {
matches <- football_data_ext %>%
select(1:9) %>%
filter(home_team %in% c(first_team, second_team)
& away_team %in% c(first_team, second_team))
return(matches)
}
getMatchesList("England", "Scotland")
# Functions
getMatchesList <- function(first_team, second_team) {
matches <- football_data_ext %>%
filter(home_team %in% c(first_team, second_team)
& away_team %in% c(first_team, second_team))
return(matches)
}
getMatchesList("England", "Scotland")
test <- getMatchesList("England", "Scotland")
runApp()
getBalance(test, "England", "Scotland")
barplot(getBalance(
getMatchesList(input$first_team, input$second_team, football_data_ext)))
runApp()
bal <- getBalance(getMatchesList(input$first_team, input$second_team, football_data_ext))
bal <- getBalance(getMatchesList("England", "Scotland", football_data_ext))
bal
runApp()
runApp()
bal.n
bal <- getBalance(getMatchesList("England", "Scotland", football_data_ext))
bal.n
bal$n
runApp()
bal$n
runApp()
typeof(bal)
runApp()
runApp()
runApp()
runApp()
runApp()
View(bal)
runApp()
runApp()
runApp()
runApp()
runApp()
runApp()
runApp()
runApp()
runApp()
runApp()