Updated readme
This commit is contained in:
parent
553164e6bf
commit
b69c80c37b
406
.Rhistory
406
.Rhistory
@ -1,206 +1,3 @@
|
||||
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()
|
||||
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()
|
||||
shiny::runApp()
|
||||
install.packages("shinythemes")
|
||||
runApp()
|
||||
runApp()
|
||||
runApp()
|
||||
View(test)
|
||||
View(balance)
|
||||
View(bal)
|
||||
balancePercTest <- bal %>% mutate(percentage = n/sum(.$n))
|
||||
head(balancePercTest)
|
||||
runApp()
|
||||
runApp()
|
||||
runApp()
|
||||
runApp()
|
||||
runApp()
|
||||
balPerc <- getBalancePercentage(
|
||||
getBalance(getMatchesList(input$first_team, input$second_team, football_data_ext))
|
||||
)
|
||||
runApp()
|
||||
@ -510,3 +307,206 @@ merge.data.frame(as.data.frame(home_teams), as.data.frame(away_teams))
|
||||
merge(home_teams, away_teams)
|
||||
merge(home_teams$home_team, away_teams$away_team)
|
||||
home_teams %>% mutate(home_team = away_team)
|
||||
shiny::runApp()
|
||||
runApp()
|
||||
runApp()
|
||||
rlang::last_error()
|
||||
teams <- home_teams + away_teams
|
||||
teams
|
||||
pd.concat()
|
||||
library(pandas)
|
||||
install.packages("pandas")
|
||||
home_teams[away_teams]
|
||||
test <- merge(home_teams, away_teams, c("home_team", "away_team"))
|
||||
head(home_teams)
|
||||
as.list(home_teams)
|
||||
test <- as.list(home_teams)
|
||||
test2 <- as.list(away_teams)
|
||||
test + test2
|
||||
merge(home_teams, away_teams, home_teams$home_team, away_teams$away_team)
|
||||
merge(home_teams, away_teams, by.x = "home_team", by.y = "away_team")
|
||||
merge(home_teams, away_teams, by.x = "home_team", by.y = "away_team") %>% unique()
|
||||
merge(home_teams, away_teams, by.x = "home_team", by.y = "away_team")
|
||||
runApp()
|
||||
runApp()
|
||||
runApp()
|
||||
runApp()
|
||||
runApp()
|
||||
tournament_types <- football_data %>%
|
||||
select(tournament) %>% unique()
|
||||
tournament_types
|
||||
runApp()
|
||||
football_data %>%
|
||||
select(tournament) %>% unique() %>% as.list()
|
||||
runApp()
|
||||
as.vector(football_data$tournament)
|
||||
football_data$tournament %>% unique() %>% as.vector()
|
||||
runApp()
|
||||
tournament_types <- football_data %>%
|
||||
pull(tournament)
|
||||
tournament_types
|
||||
tournament_types %>% unique()
|
||||
runApp()
|
||||
runApp()
|
||||
runApp()
|
||||
runApp()
|
||||
install.packages("shinywidgets")
|
||||
runApp()
|
||||
install.packages("shinyWidgets")
|
||||
runApp()
|
||||
runApp()
|
||||
runApp()
|
||||
runApp()
|
||||
runApp()
|
||||
runApp()
|
||||
runApp()
|
||||
runApp()
|
||||
runApp()
|
||||
runApp()
|
||||
football_data %>%
|
||||
select("home_team") %>% unique() %>% sort()
|
||||
football_data %>%
|
||||
select("home_team") %>% unique()
|
||||
football_data %>%
|
||||
select("home_team") %>% unique() %>% arrange(home_teams)
|
||||
football_data %>%
|
||||
select("home_team") %>% unique() %>% arrange("home_team")
|
||||
football_data %>%
|
||||
select("home_team") %>% unique() %>% arrange(., "home_team")
|
||||
football_data %>%
|
||||
select("home_team") %>% unique() %>% arrange("home_team")
|
||||
football_data %>%
|
||||
select("home_team") %>% unique() %>% arrange()
|
||||
football_data %>%
|
||||
select("home_team") %>% arrange("home_team") %>% unique()
|
||||
football_data %>%
|
||||
select("home_team") %>% arrange(., "home_team") %>% unique()
|
||||
football_data %>%
|
||||
select("home_team") %>% arrange(.$home_team) %>% unique()
|
||||
runApp()
|
||||
# Prepare data
|
||||
home_teams <- football_data %>%
|
||||
select("home_team") %>% unique()
|
||||
runApp()
|
||||
runApp()
|
||||
runApp()
|
||||
runApp()
|
||||
runApp()
|
||||
runApp()
|
||||
runApp()
|
||||
runApp()
|
||||
install.packages("gganimate")
|
||||
runApp()
|
||||
runApp()
|
||||
runApp()
|
||||
runApp()
|
||||
runApp()
|
||||
runApp()
|
||||
runApp()
|
||||
runApp()
|
||||
runApp()
|
||||
runApp()
|
||||
runApp()
|
||||
git status
|
||||
runApp()
|
||||
getFilteredResultsForTeam(input)
|
||||
getMatchesForTeam(football_data, "England") %>%
|
||||
filterByDate(as_date(input$date_range[1]), as_date(input$date_range[2]))
|
||||
getMatchesForTeam(football_data, "England")
|
||||
runApp()
|
||||
runApp()
|
||||
getBalanceForTeam <- function(football_data, team) {
|
||||
balance <- football_data %>%
|
||||
count(winner, sort = TRUE)
|
||||
return(balance)
|
||||
}
|
||||
getBalanceForTeam(football_data = football_data, "England")
|
||||
getBalanceForTeam(football_data = getMatchesForTeam("England"), "England")
|
||||
getMatchesForTeam("England")
|
||||
getMatchesForTeam(football_data, "England")
|
||||
getBalanceForTeam(football_data = getMatchesForTeam(football_data, "England"), "England")
|
||||
test <- getBalanceForTeam(football_data = getMatchesForTeam(football_data, "England"), "England")
|
||||
test2 <- test[!(test$winner !%in% c("England", "Draw"))]
|
||||
test2 <- test[!(test$winner %in% c("England", "Draw"))]
|
||||
test2 <- test[!(test$winner == "England")]
|
||||
test2 <- test[(test$winner == "England")]
|
||||
test2 <- test[!(test$winner == "England"),]
|
||||
head(test2)
|
||||
test2 <- test[!(test$winner %in% c("England", "Draw")),]
|
||||
head(test2)
|
||||
sum(test[!(test$winner %in% c("England", "Draw")),])
|
||||
sum(test[!(test$winner %in% c("England", "Draw")),]$n)
|
||||
football_data[!(football_data$winner %in% c("England", "Draw")),]$n
|
||||
test[!(test$winner %in% c("England", "Draw")),]$n
|
||||
test[!(test$winner %in% c("England", "Draw")),]
|
||||
test[(test$winner %in% c("England", "Draw")),]
|
||||
runApp()
|
||||
runApp()
|
||||
# Tab 1
|
||||
matchesForTeam(input, output)
|
||||
runApp()
|
||||
getBalanceForTeam <- function(football_data, team) {
|
||||
balance_full <- football_data %>%
|
||||
count(winner, sort = TRUE)
|
||||
balance <- football_data[(football_data$winner %in% c(team, "Draw")),]
|
||||
other_sum <- sum(football_data[!(football_data$winner %in% c(team, "Draw")),]$n)
|
||||
balance <- balance %>% rbind(c("Other", other_sum))
|
||||
return(balance)
|
||||
}
|
||||
runApp()
|
||||
runApp()
|
||||
head(test)
|
||||
runApp()
|
||||
test <- getMatchesForTeam(football_data, "England")
|
||||
balance_full <- test %>% count(winner, sort = TRUE)
|
||||
head(balance_full)
|
||||
test_bal <- balance_full[(balance_full$winner %in% c("England", "Draw"))]
|
||||
test_bal <- balance_full[(balance_full$winner %in% c("England", "Draw")),]
|
||||
head(test_bal)
|
||||
other_sum <- sum(balance_full[!(balance_full$winner %in% c("England", "Draw")),]$n)
|
||||
other_sum
|
||||
balance <- balance %>% rbind(c("Other", other_sum))
|
||||
test_bal <- test_bal %>% rbind(c("Other", other_sum))
|
||||
head(test_bal)
|
||||
runApp()
|
||||
runApp()
|
||||
runApp()
|
||||
runApp()
|
||||
runApp()
|
||||
runApp()
|
||||
runApp()
|
||||
test_bal
|
||||
runApp()
|
||||
test <- getMatchesForTeam(football_data, "Abkhazia")
|
||||
balance_full <- test %>% count(winner, sort = TRUE)
|
||||
head(balance_full)
|
||||
runApp()
|
||||
balance_full
|
||||
balance
|
||||
test_bal <- balance_full[(balance_full$winner %in% c("England", "Draw")),]
|
||||
other_sum <- sum(balance_full[!(balance_full$winner %in% c("Abkhazia", "Draw")),]$n)
|
||||
test_bal <- balance_full[(balance_full$winner %in% c("Abkhazia", "Draw")),]
|
||||
balance <- test_bal %>% rbind(c("Other", other_sum))
|
||||
balance
|
||||
str(balance[3])
|
||||
str(balance)
|
||||
balance <- test_bal %>% rbind(c("Other", as.numeric(other_sum)))
|
||||
str(balance)
|
||||
balance <- test_bal %>% rbind(c("Other", as.integer(other_sum)))
|
||||
str(balance)
|
||||
runApp()
|
||||
runApp()
|
||||
runApp()
|
||||
runApp()
|
||||
runApp()
|
||||
runApp()
|
||||
runApp()
|
||||
runApp()
|
||||
runApp()
|
||||
runApp()
|
||||
runApp()
|
||||
runApp()
|
||||
runApp()
|
||||
runApp()
|
||||
runApp()
|
||||
runApp()
|
||||
|
37
README.md
37
README.md
@ -1,2 +1,39 @@
|
||||
# TPD-InternationalFootballResults-ShinyApp
|
||||
|
||||
## About
|
||||
|
||||
InternationalFootballResults is an interactive application for the visualization of data containing the results of international football matches from 1872 to 2018.
|
||||
|
||||
View detailed statistics for the team or pair of teams. Filter data by date range, type of tournament or country in which the match was held.
|
||||
|
||||
Data source: [International football results from 1872 to 2018](https://www.kaggle.com/martj42/international-football-results-from-1872-to-2017)
|
||||
|
||||
## Technology
|
||||
|
||||
Created with R version 3.6.0 and Shiny 1.3.2
|
||||
|
||||
### Libraries used
|
||||
|
||||
* dplyr
|
||||
* lubridate
|
||||
* ggplot2
|
||||
* scales
|
||||
* shiny
|
||||
* shinythemes
|
||||
* shinyWidgets
|
||||
|
||||
## Done
|
||||
|
||||
* Balance for two teams ✔
|
||||
* Balance for one team ✔
|
||||
* Basic layout ✔
|
||||
* Barplot for percentage balance ✔
|
||||
|
||||
## TODO
|
||||
|
||||
* Basic summary statistics per team/teams ⛔
|
||||
* Exception handling ⛔
|
||||
* Country filtering ⚠
|
||||
* Fix for columns naming in data table ⚠
|
||||
* Add screenshots to readme
|
||||
* Kind of map
|
Loading…
Reference in New Issue
Block a user