-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdataInput.R
More file actions
107 lines (95 loc) · 1.89 KB
/
dataInput.R
File metadata and controls
107 lines (95 loc) · 1.89 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
# lastRevisited <- "2019-09-24"
# versionApp <- "v0.3"
#
# #### Load packages ####
# library(shiny)
# library(shinyjs)
# library(shinydashboard)
# library(jsonlite)
# library(tidyverse)
# library(plotly)
# library(rstudioapi)
# library(lubridate)
# library(DT)
#
#
# gen1 <- 1
# gen2 <- 2
# gen3 <- 3
# gen4 <- 4
# gen5 <- 5
# maxCP <- 3600
# minCP <- 10
# minDPS <- 0
# maxDPS <- 50
#
# source("ui.R")
# source("server.R")
Gen1 <- function(x) {
bool <- x >= 1 && x <= 151
return(bool)
}
Gen2 <- function(x) {
bool <- x >= 152 && x <= 251
return(bool)
}
Gen3 <- function(x) {
bool <- x >= 252 && x <= 386
return(bool)
}
Gen4 <- function(x) {
bool <- x >= 387 && x <= 493
return(bool)
}
Gen5 <- function(x) {
bool <- x >= 494 && x <= 649
return(bool)
}
Gen6 <- function(x) {
bool <- x >= 650 && x <= 721
return(bool)
}
Gen7 <- function(x) {
bool <- x >= 722 && x <= 809
return(bool)
}
Generation <- function(x) {
if (Gen1(x)) {
return(1)
} else if (Gen2(x)) {
return(2)
} else if (Gen3(x)) {
return(3)
} else if (Gen4(x)) {
return(4)
} else if (Gen5(x)) {
return(5)
} else if (Gen6(x)) {
return(6)
} else if (Gen7(x)) {
return(7)
} else {
stop("unknown generation pokemon")
}
}
AddGeneration <- function(data) {
withGeneration <- data %>% rowwise() %>% mutate(Generation = Generation(Nr))
return(withGeneration)
}
CountGeneration <- function(data) {
gen1 <- sum(data$Generation == 1)
gen2 <- sum(data$Generation == 2)
gen3 <- sum(data$Generation == 3)
gen4 <- sum(data$Generation == 4)
gen5 <- sum(data$Generation == 5)
gen6 <- sum(data$Generation == 6)
gen7 <- sum(data$Generation == 7)
output = list("gen1" = gen1,
"gen2" = gen2,
"gen3" = gen3,
"gen4" = gen4,
"gen5" = gen5,
"gen6" = gen6,
"gen7" = gen7)
return(output)
}