forked from rich-iannone/pointblank-workshop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstorms-validation.R
149 lines (147 loc) · 3.8 KB
/
storms-validation.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
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
library(pointblank)
agent <-
create_agent(
tbl = ~dplyr::storms,
actions = action_levels(
warn_at = 0.05,
stop_at = 0.10
),
tbl_name = "storms",
label = "Validation plan generated by `draft_validation()`."
) %>%
# Expect that column `name` is of type: character
col_is_character(
columns = vars(name)
) %>%
# Expect that column `year` is of type: numeric
col_is_numeric(
columns = vars(year)
) %>%
# Expect that values in `year` should be between `1975` and `2020`
col_vals_between(
columns = vars(year),
left = 1975,
right = 2020
) %>%
# Expect that column `month` is of type: numeric
col_is_numeric(
columns = vars(month)
) %>%
# Expect that values in `month` should be between `1` and `12`
col_vals_between(
columns = vars(month),
left = 1,
right = 12
) %>%
# Expect that column `day` is of type: integer
col_is_integer(
columns = vars(day)
) %>%
# Expect that values in `day` should be between `1` and `31`
col_vals_between(
columns = vars(day),
left = 1,
right = 31
) %>%
# Expect that column `hour` is of type: numeric
col_is_numeric(
columns = vars(hour)
) %>%
# Expect that values in `hour` should be between `0` and `23`
col_vals_between(
columns = vars(hour),
left = 0,
right = 23
) %>%
# Expect that column `lat` is of type: numeric
col_is_numeric(
columns = vars(lat)
) %>%
# Expect that values in `lat` should be between `-90` and `90`
col_vals_between(
columns = vars(lat),
left = -90,
right = 90
) %>%
# Expect that column `long` is of type: numeric
col_is_numeric(
columns = vars(long)
) %>%
# Expect that values in `long` should be between `-180` and `180`
col_vals_between(
columns = vars(long),
left = -180,
right = 180
) %>%
# Expect that column `status` is of type: character
col_is_character(
columns = vars(status)
) %>%
# Expect that column `category` is of type: factor
col_is_factor(
columns = vars(category)
) %>%
# Expect that column `wind` is of type: integer
col_is_integer(
columns = vars(wind)
) %>%
# Expect that values in `wind` should be between `10` and `160`
col_vals_between(
columns = vars(wind),
left = 10,
right = 160
) %>%
# Expect that column `pressure` is of type: integer
col_is_integer(
columns = vars(pressure)
) %>%
# Expect that values in `pressure` should be between `882` and `1022`
col_vals_between(
columns = vars(pressure),
left = 882,
right = 1022
) %>%
# Expect that column `tropicalstorm_force_diameter` is of type: integer
col_is_integer(
columns = vars(tropicalstorm_force_diameter)
) %>%
# Expect that values in `tropicalstorm_force_diameter` should be between `0` and `870`
col_vals_between(
columns = vars(tropicalstorm_force_diameter),
left = 0,
right = 870,
na_pass = TRUE
) %>%
# Expect that column `hurricane_force_diameter` is of type: integer
col_is_integer(
columns = vars(hurricane_force_diameter)
) %>%
# Expect that values in `hurricane_force_diameter` should be between `0` and `300`
col_vals_between(
columns = vars(hurricane_force_diameter),
left = 0,
right = 300,
na_pass = TRUE
) %>%
# Expect entirely distinct rows across all columns
rows_distinct() %>%
# Expect that column schemas match
col_schema_match(
schema = col_schema(
name = "character",
year = "numeric",
month = "numeric",
day = "integer",
hour = "numeric",
lat = "numeric",
long = "numeric",
status = "character",
category = c("ordered", "factor"),
wind = "integer",
pressure = "integer",
tropicalstorm_force_diameter = "integer",
hurricane_force_diameter = "integer"
)
) %>%
interrogate()
agent