-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathntop_function.R
61 lines (57 loc) · 1.53 KB
/
ntop_function.R
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
ntop_data <- function(data, n, filtertype) {
# "case" "death" recovered "date_case" "date_death" date_recovered
#####
filter_ntop_case <- function(data, n) {
data %>%
group_by(Province) %>%
transmute(sum_cases = sum(Cases)) %>%
arrange(-sum_cases) %>%
distinct() %>%
head(n)
}
# filter_ntopCountry_Cases(data,20)
filter_ntop_death <- function(data, n) {
data %>%
group_by(Province) %>%
transmute(sum_death = sum(Deaths)) %>%
arrange(-sum_death) %>%
distinct() %>%
head(n)
}
# filter_ntopCountry_recovered
filter_ntop_recovered <- function(data, n) {
data %>%
group_by(Province) %>%
transmute(sum_recovered = sum(Recovered)) %>%
arrange(-sum_recovered) %>%
distinct() %>%
head(n)
}
# filter_ntopCountry_Deaths(data,10)
filter_ntop_date_case <- function(data, n) {
data %>%
group_by(DateRep) %>%
transmute(sum_cases = sum(Cases)) %>%
arrange(-sum_cases) %>%
distinct() %>%
head(n)
}
# filter_ntopDate_Cases(data,10)
filter_ntop_date_death <- function(data, n) {
data %>%
group_by(DateRep) %>%
transmute(sum_death = sum(Deaths)) %>%
arrange(-sum_death) %>%
distinct() %>%
head(n)
}
filter_ntop_date_recovered <- function(data, n) {
data %>%
group_by(DateRep) %>%
transmute(sum_recovered = sum(Recovered)) %>%
arrange(-sum_recovered) %>%
distinct() %>%
head(n)
}
eval(call(paste0("filter_ntop_", filtertype), data, n))
}