From dae859c2ee829eb00eaaccd7f206b1cac285f201 Mon Sep 17 00:00:00 2001 From: John Gatward Date: Tue, 4 Aug 2026 19:38:46 +0100 Subject: [PATCH] [main]: clean up --- .Rproj.user/461AD266/pcs/files-pane.pper | 9 -- .Rproj.user/461AD266/pcs/source-pane.pper | 3 - .../461AD266/pcs/windowlayoutstate.pper | 14 -- .Rproj.user/461AD266/pcs/workbench-pane.pper | 5 - .Rproj.user/461AD266/sources/prop/9DEA2FB2 | 4 - .Rproj.user/461AD266/sources/prop/INDEX | 1 - .../sources/session-9bca3639/2E827BA4 | 24 ---- .../session-9bca3639/2E827BA4-contents | 126 ------------------ .../sources/session-9bca3639/lock_file | 0 .../shared/notebooks/patch-chunk-names | 0 .gitignore | 21 +++ football_competitiveness.Rproj | 13 -- 12 files changed, 21 insertions(+), 199 deletions(-) delete mode 100644 .Rproj.user/461AD266/pcs/files-pane.pper delete mode 100644 .Rproj.user/461AD266/pcs/source-pane.pper delete mode 100644 .Rproj.user/461AD266/pcs/windowlayoutstate.pper delete mode 100644 .Rproj.user/461AD266/pcs/workbench-pane.pper delete mode 100644 .Rproj.user/461AD266/sources/prop/9DEA2FB2 delete mode 100644 .Rproj.user/461AD266/sources/prop/INDEX delete mode 100644 .Rproj.user/461AD266/sources/session-9bca3639/2E827BA4 delete mode 100644 .Rproj.user/461AD266/sources/session-9bca3639/2E827BA4-contents delete mode 100644 .Rproj.user/461AD266/sources/session-9bca3639/lock_file delete mode 100644 .Rproj.user/shared/notebooks/patch-chunk-names create mode 100644 .gitignore delete mode 100644 football_competitiveness.Rproj diff --git a/.Rproj.user/461AD266/pcs/files-pane.pper b/.Rproj.user/461AD266/pcs/files-pane.pper deleted file mode 100644 index 679cb0f..0000000 --- a/.Rproj.user/461AD266/pcs/files-pane.pper +++ /dev/null @@ -1,9 +0,0 @@ -{ - "path": "~/football_competitiveness", - "sortOrder": [ - { - "columnIndex": 2, - "ascending": true - } - ] -} \ No newline at end of file diff --git a/.Rproj.user/461AD266/pcs/source-pane.pper b/.Rproj.user/461AD266/pcs/source-pane.pper deleted file mode 100644 index 902cc6f..0000000 --- a/.Rproj.user/461AD266/pcs/source-pane.pper +++ /dev/null @@ -1,3 +0,0 @@ -{ - "activeTab": 0 -} \ No newline at end of file diff --git a/.Rproj.user/461AD266/pcs/windowlayoutstate.pper b/.Rproj.user/461AD266/pcs/windowlayoutstate.pper deleted file mode 100644 index 7e58acd..0000000 --- a/.Rproj.user/461AD266/pcs/windowlayoutstate.pper +++ /dev/null @@ -1,14 +0,0 @@ -{ - "left": { - "splitterpos": 312, - "topwindowstate": "NORMAL", - "panelheight": 744, - "windowheight": 782 - }, - "right": { - "splitterpos": 469, - "topwindowstate": "NORMAL", - "panelheight": 744, - "windowheight": 782 - } -} \ No newline at end of file diff --git a/.Rproj.user/461AD266/pcs/workbench-pane.pper b/.Rproj.user/461AD266/pcs/workbench-pane.pper deleted file mode 100644 index 75e70e9..0000000 --- a/.Rproj.user/461AD266/pcs/workbench-pane.pper +++ /dev/null @@ -1,5 +0,0 @@ -{ - "TabSet1": 0, - "TabSet2": 0, - "TabZoom": {} -} \ No newline at end of file diff --git a/.Rproj.user/461AD266/sources/prop/9DEA2FB2 b/.Rproj.user/461AD266/sources/prop/9DEA2FB2 deleted file mode 100644 index bb27690..0000000 --- a/.Rproj.user/461AD266/sources/prop/9DEA2FB2 +++ /dev/null @@ -1,4 +0,0 @@ -{ - "source_window_id": "", - "Source": "Source" -} \ No newline at end of file diff --git a/.Rproj.user/461AD266/sources/prop/INDEX b/.Rproj.user/461AD266/sources/prop/INDEX deleted file mode 100644 index 5a0e4bf..0000000 --- a/.Rproj.user/461AD266/sources/prop/INDEX +++ /dev/null @@ -1 +0,0 @@ -~%2Ffootball_competitiveness%2Fdata_manipulation.R="9DEA2FB2" diff --git a/.Rproj.user/461AD266/sources/session-9bca3639/2E827BA4 b/.Rproj.user/461AD266/sources/session-9bca3639/2E827BA4 deleted file mode 100644 index a700092..0000000 --- a/.Rproj.user/461AD266/sources/session-9bca3639/2E827BA4 +++ /dev/null @@ -1,24 +0,0 @@ -{ - "id": "2E827BA4", - "path": "~/football_competitiveness/data_manipulation.R", - "project_path": "data_manipulation.R", - "type": "r_source", - "hash": "0", - "contents": "", - "dirty": false, - "created": 1785865647905.0, - "source_on_save": false, - "relative_order": 1, - "properties": { - "source_window_id": "", - "Source": "Source" - }, - "folds": "", - "lastKnownWriteTime": 1785865410, - "encoding": "UTF-8", - "collab_server": "", - "source_window": "", - "last_content_update": 1785865410, - "read_only": false, - "read_only_alternatives": [] -} \ No newline at end of file diff --git a/.Rproj.user/461AD266/sources/session-9bca3639/2E827BA4-contents b/.Rproj.user/461AD266/sources/session-9bca3639/2E827BA4-contents deleted file mode 100644 index 65716a0..0000000 --- a/.Rproj.user/461AD266/sources/session-9bca3639/2E827BA4-contents +++ /dev/null @@ -1,126 +0,0 @@ -European_performance_data = read_csv('Data/European performance historical data.csv') -Points_difference_data <- read_csv("Data/Points difference.csv") -Players_used_data <- read_csv("Data/European clubs number of players used.csv") -Top_goalscorers_data <- read_csv("Data/Average top scorers.csv") -Market_value_data <- read_csv("Data/Market values.csv") -gini_coeffecient_data <- Market_value_data %>% - select(-`Average market value of clubs`) -all_seasons <- unique(European_performance_data$Season) - -overall_country_performance <- European_performance_data %>% - group_by(Country) %>% - summarise(total_performance = sum(European_performance, na.rm = TRUE)) %>% - arrange(desc(total_performance)) - -#season by season performance -country_performance_by_season <- European_performance_data %>% - filter(Country %in% c("Germany", "Spain", "England", "Portugal", "Italy", "France")) %>% - group_by(Country, Season) %>% - summarise( - European_performance = sum(European_performance, na.rm = TRUE), - .groups = "drop" - ) %>% - complete(Country, Season = all_seasons, fill = list(European_performance = 0)) -#season by season performance by competition -country_performance_by_season_comp_breakdown <- European_performance_data %>% - filter(Country %in% c("Germany", "Spain", "England", "Portugal", "Italy", "France")) %>% - group_by(Country, Season) %>% - summarise( - CL = sum(European_performance[Competition == "CL"], na.rm = TRUE), - EL = sum(European_performance[Competition == "EL"], na.rm = TRUE), - .groups = "drop" - ) %>% - complete(Country, Season = all_seasons, fill = list(CL = 0, EL = 0)) %>% - pivot_longer(cols = c("CL", "EL"), names_to = "competition", values_to = "European_performance") %>% - mutate(European_performance = ifelse(competition == "CL", European_performance/2, European_performance)) #halving score for CL as had double weighting - -#join all metrics data together -#impute missing Gini coefficient with average for league - assumed the same over time -season_league_metrics_dataset <- Points_difference_data %>% - left_join(Players_used_data, by = c("Country", "Season")) %>% - left_join(Top_goalscorers_data, by = c("Country", "Season")) %>% - left_join(gini_coeffecient_data, by = c("Country", "Season")) %>% - mutate(season_start = as.integer(str_extract(Season, "^\\d{4}"))) %>% - group_by(Country) %>% - mutate(Gini_coefficient = coalesce(Gini_coefficient, mean(Gini_coefficient, na.rm = TRUE))) %>% - ungroup() - -#average country performance -average_country_metrics <- season_league_metrics_dataset %>% - group_by(Country) %>% - summarise(across(!contains("eason"), mean, na.rm = TRUE)) - -#scaling to min-max of variables -average_country_metrics_scaled <- average_country_metrics -average_country_metrics_scaled[,-1] <- lapply(average_country_metrics[,-1], function(x) { - (x - min(x)) / (max(x) - min(x)) -}) - -#scaling metrics normally -scaled_metrics_data <- season_league_metrics_dataset %>% - mutate(across( - c(First_and_second, First_and_CL, First_and_relegated, CL_and_relegated, - Winners_GD, Top_4_total_GD, Average_number_of_players, - Average_goals_by_top_3_players, Gini_coefficient), - ~ as.numeric(scale(.)) - )) - -#join metrics data to European performance data -#calculate European performance in next season as lead -season_league_full_dataset <- season_league_metrics_dataset %>% - left_join(country_performance_by_season, by = c("Country", "Season")) %>% - arrange(Season, Country) %>% - group_by(Country) %>% - mutate(lead_european_performance = dplyr::lead(European_performance)) %>% - ungroup() - -#join metrics data to European performance data by competition -#calculate European performance in next season as lead -season_league_full_dataset_comp_breakdown <- season_league_metrics_dataset %>% - left_join(country_performance_by_season_comp_breakdown, by = c("Country", "Season")) %>% - arrange(Season, Country) %>% - group_by(Country, competition) %>% - mutate(lead_european_performance = dplyr::lead(European_performance)) %>% - ungroup() - -#full data scaled -scaled_full_data <- scaled_metrics_data %>% - left_join(country_performance_by_season, by = c("Country", "Season")) %>% - arrange(Season, Country) %>% - group_by(Country) %>% - mutate(lead_european_performance = dplyr::lead(European_performance)) %>% - ungroup() - -#data by competition scaled -scaled_full_data_comp_breakdown <- scaled_metrics_data %>% - left_join(country_performance_by_season_comp_breakdown, by = c("Country", "Season")) %>% - arrange(Season, Country) %>% - group_by(Country, competition) %>% - mutate(lead_european_performance = dplyr::lead(European_performance)) %>% - ungroup() - -#full dataset with competition breakdown and full -pivoted_scaled_full_data_comp_breakdown <- scaled_full_data_comp_breakdown %>% - pivot_wider(names_from = competition, values_from = c(European_performance, lead_european_performance)) %>% - mutate(European_performance = 2*European_performance_CL + European_performance_EL, - lead_european_performance = 2*lead_european_performance_CL + lead_european_performance_EL) - -#basic profiling based on European performance -quantile_splits <- scaled_full_data %>% - mutate( - performance_group = ntile(European_performance, 3) - ) -european_performance_groups_characteristics <- quantile_splits %>% - group_by(performance_group) %>% - summarise(across(where(is.numeric), mean, na.rm = TRUE)) %>% - select(-season_start) %>% - mutate(label = case_when( - performance_group == 1 ~ "Worst performing", - performance_group == 2 ~ "Middle performing", - performance_group == 3 ~ "Best performing" - )) %>% - mutate(performance_group = case_when( - label == "Worst performing" ~ 1, - label == "Middle performing" ~ 3, - label == "Best performing" ~ 2 - )) diff --git a/.Rproj.user/461AD266/sources/session-9bca3639/lock_file b/.Rproj.user/461AD266/sources/session-9bca3639/lock_file deleted file mode 100644 index e69de29..0000000 diff --git a/.Rproj.user/shared/notebooks/patch-chunk-names b/.Rproj.user/shared/notebooks/patch-chunk-names deleted file mode 100644 index e69de29..0000000 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5a242ad --- /dev/null +++ b/.gitignore @@ -0,0 +1,21 @@ +# R session files +.Rhistory +.Rapp.history +.RData +.RDataTmp +.Ruserdata + +# RStudio project/user state +.Rproj.user/ + +# renv local library/state (keep renv.lock and renv/activate.R tracked) +renv/library/ +renv/python/ +renv/staging/ + +# IDE/project metadata +.idea/ +.vscode/ + +# OS cruft +.DS_Store diff --git a/football_competitiveness.Rproj b/football_competitiveness.Rproj deleted file mode 100644 index 3af27f6..0000000 --- a/football_competitiveness.Rproj +++ /dev/null @@ -1,13 +0,0 @@ -Version: 1.0 - -RestoreWorkspace: Default -SaveWorkspace: Default -AlwaysSaveHistory: Default - -EnableCodeIndexing: Yes -UseSpacesForTab: Yes -NumSpacesForTab: 2 -Encoding: UTF-8 - -RnwWeave: Sweave -LaTeX: pdfLaTeX