158 lines
4.2 KiB
R
158 lines
4.2 KiB
R
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()
|