Skip to content

Commit eb567fe

Browse files
committed
lint: fix tribble jank
1 parent a168561 commit eb567fe

File tree

6 files changed

+110
-355
lines changed

6 files changed

+110
-355
lines changed

R/aux_data_utils.R

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -596,27 +596,18 @@ gen_ili_data <- function(default_day_of_week = 1) {
596596
# map names to lower case
597597
name_map <- tibble(abb = state.abb, name = state.name) %>%
598598
bind_rows(
599+
# fmt: skip
599600
tribble(
600-
~name,
601-
~abb,
602-
"District of Columbia",
603-
"DC",
604-
"American Samoa",
605-
"AS",
606-
"Guam",
607-
"GU",
608-
"Northern Mariana Islands",
609-
"MP",
610-
"Puerto Rico",
611-
"PR",
612-
"Virgin Islands",
613-
"VI",
614-
"Trust Territories",
615-
"TT",
616-
"us",
617-
"US",
618-
"New York City",
619-
"ny"
601+
~name, ~abb,
602+
"District of Columbia", "DC",
603+
"American Samoa", "AS",
604+
"Guam", "GU",
605+
"Northern Mariana Islands", "MP",
606+
"Puerto Rico", "PR",
607+
"Virgin Islands", "VI",
608+
"Trust Territories", "TT",
609+
"us", "US",
610+
"New York City", "ny"
620611
)
621612
) %>%
622613
mutate(abb = tolower(abb))

scripts/one_offs/build_flusion_data.R

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -281,27 +281,18 @@ ili_plus <- bind_rows(ili_plus_HHS, ili_plus_nation, ili_plus_state) %>%
281281
# map names to lower case
282282
name_map <- tibble(abb = state.abb, name = state.name) %>%
283283
bind_rows(
284+
# fmt: skip
284285
tribble(
285-
~name,
286-
~abb,
287-
"District of Columbia",
288-
"DC",
289-
"American Samoa",
290-
"AS",
291-
"Guam",
292-
"GU",
293-
"Northern Mariana Islands",
294-
"MP",
295-
"Puerto Rico",
296-
"PR",
297-
"Virgin Islands",
298-
"VI",
299-
"Trust Territories",
300-
"TT",
301-
"us",
302-
"US",
303-
"New York City",
304-
"ny"
286+
~name, ~abb,
287+
"District of Columbia", "DC",
288+
"American Samoa", "AS",
289+
"Guam", "GU",
290+
"Northern Mariana Islands", "MP",
291+
"Puerto Rico", "PR",
292+
"Virgin Islands", "VI",
293+
"Trust Territories", "TT",
294+
"us", "US",
295+
"New York City", "ny"
305296
)
306297
) %>%
307298
mutate(abb = tolower(abb))

tests/testthat/test-daily-weekly-archive.R

Lines changed: 54 additions & 200 deletions
Original file line numberDiff line numberDiff line change
@@ -3,229 +3,83 @@ suppressPackageStartupMessages(source(here::here("R", "load_all.R")))
33
# Works correctly if you have exactly one version where the previous Friday data
44
# is the latest so it is ignored and the week before THAT is summed (10-27 to
55
# 11-02), but is then dated to the Wednesday of the week (10-30).
6+
# fmt: skip
67
tribble(
7-
~geo_value,
8-
~time_value,
9-
~version,
10-
~value,
11-
"us",
12-
"2024-11-08",
13-
"2024-11-13",
14-
1,
15-
"us",
16-
"2024-11-07",
17-
"2024-11-13",
18-
2,
19-
"us",
20-
"2024-11-06",
21-
"2024-11-13",
22-
3,
23-
"us",
24-
"2024-11-05",
25-
"2024-11-13",
26-
4,
27-
"us",
28-
"2024-11-04",
29-
"2024-11-13",
30-
5,
31-
"us",
32-
"2024-11-03",
33-
"2024-11-13",
34-
6,
35-
"us",
36-
"2024-11-02",
37-
"2024-11-13",
38-
7,
39-
"us",
40-
"2024-11-01",
41-
"2024-11-13",
42-
8,
43-
"us",
44-
"2024-10-31",
45-
"2024-11-13",
46-
9,
47-
"us",
48-
"2024-10-30",
49-
"2024-11-13",
50-
10,
51-
"us",
52-
"2024-10-29",
53-
"2024-11-13",
54-
11,
55-
"us",
56-
"2024-10-28",
57-
"2024-11-13",
58-
12,
59-
"us",
60-
"2024-10-27",
61-
"2024-11-13",
62-
13
8+
~geo_value, ~time_value, ~version, ~value,
9+
"us", "2024-11-08", "2024-11-13", 1,
10+
"us", "2024-11-07", "2024-11-13", 2,
11+
"us", "2024-11-06", "2024-11-13", 3,
12+
"us", "2024-11-05", "2024-11-13", 4,
13+
"us", "2024-11-04", "2024-11-13", 5,
14+
"us", "2024-11-03", "2024-11-13", 6,
15+
"us", "2024-11-02", "2024-11-13", 7,
16+
"us", "2024-11-01", "2024-11-13", 8,
17+
"us", "2024-10-31", "2024-11-13", 9,
18+
"us", "2024-10-30", "2024-11-13", 10,
19+
"us", "2024-10-29", "2024-11-13", 11,
20+
"us", "2024-10-28", "2024-11-13", 12,
21+
"us", "2024-10-27", "2024-11-13", 13
6322
) %>%
6423
mutate(time_value = as.Date(time_value), version = as.Date(version)) %>%
6524
as_epi_archive(versions_end = as.Date("2024-11-13"), compactify = TRUE) %>%
6625
daily_to_weekly_archive("value")
6726

6827
# Same thing as above, but the versions go backwards, constant lag of 5 days
28+
# fmt: skip
6929
tribble(
70-
~geo_value,
71-
~time_value,
72-
~version,
73-
~value,
74-
"us",
75-
"2024-11-08",
76-
"2024-11-13",
77-
1,
78-
"us",
79-
"2024-11-07",
80-
"2024-11-12",
81-
2,
82-
"us",
83-
"2024-11-06",
84-
"2024-11-11",
85-
3,
86-
"us",
87-
"2024-11-05",
88-
"2024-11-10",
89-
4,
90-
"us",
91-
"2024-11-04",
92-
"2024-11-09",
93-
5,
94-
"us",
95-
"2024-11-03",
96-
"2024-11-08",
97-
6,
98-
"us",
99-
"2024-11-02",
100-
"2024-11-07",
101-
7,
102-
"us",
103-
"2024-11-01",
104-
"2024-11-06",
105-
8,
106-
"us",
107-
"2024-10-31",
108-
"2024-11-05",
109-
9,
110-
"us",
111-
"2024-10-30",
112-
"2024-11-04",
113-
10,
114-
"us",
115-
"2024-10-29",
116-
"2024-11-03",
117-
11,
118-
"us",
119-
"2024-10-28",
120-
"2024-11-02",
121-
12,
122-
"us",
123-
"2024-10-27",
124-
"2024-11-01",
125-
13
30+
~geo_value, ~time_value, ~version, ~value,
31+
"us", "2024-11-08", "2024-11-13", 1,
32+
"us", "2024-11-07", "2024-11-12", 2,
33+
"us", "2024-11-06", "2024-11-11", 3,
34+
"us", "2024-11-05", "2024-11-10", 4,
35+
"us", "2024-11-04", "2024-11-09", 5,
36+
"us", "2024-11-03", "2024-11-08", 6,
37+
"us", "2024-11-02", "2024-11-07", 7,
38+
"us", "2024-11-01", "2024-11-06", 8,
39+
"us", "2024-10-31", "2024-11-05", 9,
40+
"us", "2024-10-30", "2024-11-04", 10,
41+
"us", "2024-10-29", "2024-11-03", 11,
42+
"us", "2024-10-28", "2024-11-02", 12,
43+
"us", "2024-10-27", "2024-11-01", 13
12644
) %>%
12745
mutate(time_value = as.Date(time_value), version = as.Date(version)) %>%
12846
as_epi_archive(versions_end = as.Date("2024-11-13"), compactify = TRUE) %>%
12947
daily_to_weekly_archive("value")
13048

13149
# Now add the Friday
13250
# Same thing as above, but the versions go backwards, constant lag of 5 days
51+
# fmt: skip
13352
tribble(
134-
~geo_value,
135-
~time_value,
136-
~version,
137-
~value,
138-
"us",
139-
"2024-11-09",
140-
"2024-11-13",
141-
0.5,
142-
"us",
143-
"2024-11-08",
144-
"2024-11-13",
145-
1,
146-
"us",
147-
"2024-11-07",
148-
"2024-11-12",
149-
2,
150-
"us",
151-
"2024-11-06",
152-
"2024-11-11",
153-
3,
154-
"us",
155-
"2024-11-05",
156-
"2024-11-10",
157-
4,
158-
"us",
159-
"2024-11-04",
160-
"2024-11-09",
161-
5,
162-
"us",
163-
"2024-11-03",
164-
"2024-11-08",
165-
6,
166-
"us",
167-
"2024-11-02",
168-
"2024-11-07",
169-
7,
170-
"us",
171-
"2024-11-01",
172-
"2024-11-06",
173-
8,
174-
"us",
175-
"2024-10-31",
176-
"2024-11-05",
177-
9,
178-
"us",
179-
"2024-10-30",
180-
"2024-11-04",
181-
10,
182-
"us",
183-
"2024-10-29",
184-
"2024-11-03",
185-
11,
186-
"us",
187-
"2024-10-28",
188-
"2024-11-02",
189-
12,
190-
"us",
191-
"2024-10-27",
192-
"2024-11-01",
193-
13
53+
~geo_value, ~time_value, ~version, ~value,
54+
"us", "2024-11-09", "2024-11-13", 0.5,
55+
"us", "2024-11-08", "2024-11-13", 1,
56+
"us", "2024-11-07", "2024-11-12", 2,
57+
"us", "2024-11-06", "2024-11-11", 3,
58+
"us", "2024-11-05", "2024-11-10", 4,
59+
"us", "2024-11-04", "2024-11-09", 5,
60+
"us", "2024-11-03", "2024-11-08", 6,
61+
"us", "2024-11-02", "2024-11-07", 7,
62+
"us", "2024-11-01", "2024-11-06", 8,
63+
"us", "2024-10-31", "2024-11-05", 9,
64+
"us", "2024-10-30", "2024-11-04", 10,
65+
"us", "2024-10-29", "2024-11-03", 11,
66+
"us", "2024-10-28", "2024-11-02", 12,
67+
"us", "2024-10-27", "2024-11-01", 13
19468
) %>%
19569
mutate(time_value = as.Date(time_value), version = as.Date(version)) %>%
19670
as_epi_archive(versions_end = as.Date("2024-11-13"), compactify = TRUE) %>%
19771
daily_to_weekly_archive("value")
19872

19973
# NA
74+
# fmt: skip
20075
tribble(
201-
~geo_value,
202-
~time_value,
203-
~version,
204-
~value,
205-
"us",
206-
"2024-11-16",
207-
"2024-11-16",
208-
1,
209-
"us",
210-
"2024-11-15",
211-
"2024-11-16",
212-
2,
213-
"us",
214-
"2024-11-09",
215-
"2024-11-09",
216-
3,
217-
"us",
218-
"2024-11-08",
219-
"2024-11-09",
220-
4,
221-
"us",
222-
"2024-11-02",
223-
"2024-11-02",
224-
5,
225-
"us",
226-
"2024-11-01",
227-
"2024-11-02",
228-
6,
76+
~geo_value, ~time_value, ~version, ~value,
77+
"us", "2024-11-16", "2024-11-16", 1,
78+
"us", "2024-11-15", "2024-11-16", 2,
79+
"us", "2024-11-09", "2024-11-09", 3,
80+
"us", "2024-11-08", "2024-11-09", 4,
81+
"us", "2024-11-02", "2024-11-02", 5,
82+
"us", "2024-11-01", "2024-11-02", 6,
22983
) %>%
23084
mutate(time_value = as.Date(time_value), version = as.Date(version)) %>%
23185
as_epi_archive(.versions_end = as.Date("2024-11-16"), compactify = TRUE) %>%

0 commit comments

Comments
 (0)