-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathranking_scores_all.R
More file actions
110 lines (102 loc) · 4.55 KB
/
ranking_scores_all.R
File metadata and controls
110 lines (102 loc) · 4.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# For Linux
# Sys.setlocale(category = "LC_ALL", locale = "ru_RU.UTF-8")
# For Windows
Sys.setlocale(category = "LC_ALL", locale = "Russian_Russia.1251")
source("ranking_scores_youth.R", encoding = "UTF-8") # For youth raniking computation
source("selection_scores_youth.R", encoding = "UTF-8") # For youth selection computation
source("ranking_scores_master.R", encoding = "UTF-8") # For master ranking computation
source("ranking_scores_elite.R", encoding = "UTF-8") # For elite, sprint, mtbo and ski rankings computation
source("ranking_scores_junior.R", encoding = "UTF-8")
ranking_type = 'youth' # Available options: "youth", "junior", "master", "elite", "sprint", 'mtbo', 'ski' 'youth_selection'
coefs_comps <- data.frame()
require(googledrive)
require(googlesheets4)
if(ranking_type == "youth") {
googlesheet_name <- "Youth Ranking Starts"
} else {
if(ranking_type == "junior") {
googlesheet_name <- "Junior Ranking Starts"
} else {
if(ranking_type == "master") {
googlesheet_name <- "Master Ranking Starts"
} else {
if(ranking_type == "elite") {
googlesheet_name <- "Elite Ranking Starts"
} else {
if(ranking_type == "sprint") {
googlesheet_name <- "Sprint Ranking Starts"
} else {
if(ranking_type == "mtbo") {
googlesheet_name <- "MTBO Ranking Starts"
} else {
if(ranking_type == "ski") {
googlesheet_name <- "Ski Ranking Starts"
} else {
if(ranking_type == "youth_selection") {
googlesheet_name <- "Youth Selection Starts"
} else {
stop("Unsupported rating type!")
}
}
}
}
}
}
}
}
coefs_comps <- as.data.frame(read_sheet(drive_find(pattern = googlesheet_name,
type = "spreadsheet"),
sheet = format(Sys.Date(), "%Y")))
coefs_comps$Дата <- as.character(coefs_comps$Дата)
passed_comps <- coefs_comps[!is.na(coefs_comps$`Ссылка на результаты`), ]
if (ranking_type == "youth") {
apply(X = passed_comps, MARGIN = 1, FUN = function(x) {
ranking_scores_youth(competition_date = x["Дата"],
competition_name = x["Название"],
competition_distance = x["Вид"],
ranking_type = ranking_type,
competition_coefficient = as.numeric(x["Коэффициент"]))
})
} else {
if(ranking_type == "master") {
apply(X = passed_comps, MARGIN = 1, FUN = function(x) {
ranking_scores_master(competition_date = x["Дата"],
competition_name = x["Название"],
competition_distance = x["Вид"],
ranking_type = ranking_type,
competition_coefficient = as.numeric(x["Коэффициент"]))
})
} else {
if ((ranking_type == "elite") | (ranking_type == "sprint") | (ranking_type == "mtbo") | (ranking_type == "ski")) {
apply(X = passed_comps, MARGIN = 1, FUN = function(x) {
ranking_scores_elite(competition_date = x["Дата"],
competition_name = x["Название"],
competition_distance = x["Вид"],
ranking_type = ranking_type,
competition_coefficient = as.numeric(x["Коэффициент"]))
})
} else {
if (ranking_type == "junior") {
apply(X = passed_comps, MARGIN = 1, FUN = function(x) {
ranking_scores_junior(competition_date = x["Дата"],
competition_name = x["Название"],
competition_distance = x["Вид"],
ranking_type = ranking_type,
competition_coefficient = as.numeric(x["Коэффициент"]))
})
} else {
if (ranking_type == "youth_selection") {
apply(X = passed_comps, MARGIN = 1, FUN = function(x) {
selection_scores_youth(competition_date = x["Дата"],
competition_name = x["Название"],
competition_distance = x["Вид"],
ranking_type = ranking_type,
competition_coefficient = as.numeric(x["Коэффициент"]))
})
} else {
stop("Unsupported ranking type!")
}
}
}
}
}