Skip to content

Commit 7849626

Browse files
committed
2 parents 42cc485 + 7ecc006 commit 7849626

File tree

8 files changed

+228
-15
lines changed

8 files changed

+228
-15
lines changed

.github/workflows/python_ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ name: Python Lint and Testing
55

66
on:
77
push:
8-
branches: [ main ]
8+
branches: [ main, r-pkg-devel ]
99
pull_request:
10-
branches: [ main ]
10+
branches: [ main, r-pkg-devel ]
1111

1212
jobs:
1313
build:

.github/workflows/r_ci.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ name: R
1010

1111
on:
1212
push:
13-
branches: [ main ]
13+
branches: [ main, r-pkg-devel ]
1414
pull_request:
15-
branches: [ main ]
15+
branches: [ main, r-pkg-devel ]
1616

1717
jobs:
1818
build:
@@ -27,7 +27,7 @@ jobs:
2727
steps:
2828
- uses: actions/checkout@v2
2929
- name: Set up R ${{ matrix.r-version }}
30-
uses: r-lib/actions/setup-r@ffe45a39586f073cc2e9af79c4ba563b657dc6e3
30+
uses: r-lib/actions/setup-r@v1
3131
with:
3232
r-version: ${{ matrix.r-version }}
3333
- name: Install linux dependencies
@@ -39,7 +39,7 @@ jobs:
3939
uses: actions/cache@v2
4040
with:
4141
path: ${{ env.R_LIBS_USER }}
42-
key: ${{ runner.os }}-r-1-
42+
key: ${{ runner.os }}-r-2-
4343
- name: Install dependencies
4444
run: |
4545
install.packages(c("remotes", "rcmdcheck"))
@@ -48,4 +48,4 @@ jobs:
4848
- name: Check
4949
run: |
5050
rcmdcheck::rcmdcheck(args = c("--no-manual", "--ignore-vignettes", "--as-cran"), build_args = c("--no-build-vignettes"), error_on = "error")
51-
shell: Rscript {0}
51+
shell: Rscript {0}

R-notebooks/dashboard_functions.R

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,15 @@ plot_28_day_frequency_state <- function(df_to_plot) {
1313

1414
covidcast_signal_to_plot = make_covidcast_signal(states_present, df_to_plot, "state")
1515

16-
plot(covidcast_signal_to_plot,
17-
title = sprintf(
18-
"State frequency in last 28 days (start date: %s)",
19-
covidcast_signal_to_plot$time_value[1]
20-
),
21-
range = c(0, 28))
16+
plot(
17+
covidcast_signal_to_plot,
18+
title = sprintf(
19+
"State frequency in last 28 days (start date: %s); grey = no data for state.",
20+
covidcast_signal_to_plot$time_value[1]
21+
),
22+
range = c(1, 28),
23+
choro_params = list(legend_digits = 0)
24+
)
2225
}
2326

2427
plot_28_day_frequency_county <- function(df_to_plot) {
@@ -32,9 +35,10 @@ plot_28_day_frequency_county <- function(df_to_plot) {
3235
plot(
3336
covidcast_signal_to_plot,
3437
title = sprintf(
35-
"County frequency in last 28 days (start date: %s)",
38+
"County frequency in last 28 days (start date: %s); grey = no data for county.",
3639
covidcast_signal_to_plot$time_value[1]
3740
),
38-
range = c(0, 28)
41+
range = c(1, 28),
42+
choro_params = list(legend_digits = 0)
3943
)
4044
}

R-notebooks/jhu_dashboard.Rmd

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
---
2+
title: "JHU dashboard"
3+
author: "Delphi Lab"
4+
date: "`r format(Sys.time(), '%B %d, %Y')`"
5+
output:
6+
html_document:
7+
code_folding: hide
8+
---
9+
10+
```{r, include = FALSE}
11+
knitr::opts_chunk$set(message = FALSE, warning = FALSE)
12+
```
13+
14+
```{r}
15+
library(covidcast)
16+
library(dplyr)
17+
library(ggplot2)
18+
19+
date_scale <-
20+
scale_x_date(date_breaks = "1 week", date_labels = "%b %d")
21+
22+
twenty_eight_days_ago = Sys.Date() - 28
23+
```
24+
25+
26+
### Coverage
27+
28+
This measures how much county coverage we have in the samples (i.e., how many unique counties are present each day), and how it has recently changed over time.
29+
30+
```{r, fig.width = 7, fig.height = 5}
31+
32+
# Sampling coverage
33+
df_jhu_counties = covidcast_signal(
34+
"jhu-csse",
35+
"confirmed_7dav_cumulative_num",
36+
start_day = twenty_eight_days_ago,
37+
geo_type = "county"
38+
)
39+
counties_per_day = df_jhu_counties %>%
40+
group_by(time_value) %>%
41+
summarize(n = n())
42+
43+
ggplot(counties_per_day, aes(x = time_value, y = n)) +
44+
geom_line() + geom_point() + theme_bw() +
45+
labs(
46+
x = "Date",
47+
y = "Number of Counties",
48+
title = sprintf(
49+
"Unique Counties: %i, mean per day: %i",
50+
length(unique(
51+
df_jhu_counties$geo_value
52+
)),
53+
round(mean(counties_per_day$n))
54+
)
55+
) + date_scale
56+
```
57+
58+
## County Coverage Map
59+
60+
This visualizes the county coverage -- how frequently does each county show up in the data over the last 28 days?
61+
62+
```{r, fig.width = 10, fig.height = 8}
63+
64+
source("dashboard_functions.R")
65+
plot_28_day_frequency_county(df_jhu_counties)
66+
67+
```
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
---
2+
title: "Safegraph dashboard"
3+
author: "Delphi Lab"
4+
date: "`r format(Sys.time(), '%B %d, %Y')`"
5+
output:
6+
html_document:
7+
code_folding: hide
8+
---
9+
10+
```{r, include = FALSE}
11+
knitr::opts_chunk$set(message = FALSE, warning = FALSE)
12+
```
13+
14+
```{r}
15+
library(covidcast)
16+
library(dplyr)
17+
library(ggplot2)
18+
19+
date_scale <-
20+
scale_x_date(date_breaks = "1 week", date_labels = "%b %d")
21+
22+
twenty_eight_days_ago = Sys.Date() - 28
23+
```
24+
25+
26+
### Coverage
27+
28+
This measures how much county coverage we have in the samples (i.e., how many unique counties are present each day), and how it has recently changed over time.
29+
30+
```{r, fig.width = 7, fig.height = 5}
31+
32+
# Sampling coverage
33+
df_safegraph_counties = covidcast_signal(
34+
"safegraph",
35+
"median_home_dwell_time",
36+
start_day = twenty_eight_days_ago,
37+
geo_type = "county"
38+
)
39+
counties_per_day = df_safegraph_counties %>%
40+
group_by(time_value) %>%
41+
summarize(n = n())
42+
43+
ggplot(counties_per_day, aes(x = time_value, y = n)) +
44+
geom_line() + geom_point() + theme_bw() +
45+
labs(
46+
x = "Date",
47+
y = "Number of Counties",
48+
title = sprintf(
49+
"Unique Counties: %i, mean per day: %i",
50+
length(unique(
51+
df_safegraph_counties$geo_value
52+
)),
53+
round(mean(counties_per_day$n))
54+
)
55+
) + date_scale
56+
```
57+
58+
## County Coverage Map
59+
60+
This visualizes the county coverage -- how frequently does each county show up in the data over the last 28 days?
61+
62+
```{r, fig.width = 10, fig.height = 8}
63+
64+
source("dashboard_functions.R")
65+
plot_28_day_frequency_county(df_safegraph_counties)
66+
67+
```
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
---
2+
title: "USA facts dashboard"
3+
author: "Delphi Lab"
4+
date: "`r format(Sys.time(), '%B %d, %Y')`"
5+
output:
6+
html_document:
7+
code_folding: hide
8+
---
9+
10+
```{r, include = FALSE}
11+
knitr::opts_chunk$set(message = FALSE, warning = FALSE)
12+
```
13+
14+
```{r}
15+
library(covidcast)
16+
library(dplyr)
17+
library(ggplot2)
18+
19+
date_scale <-
20+
scale_x_date(date_breaks = "1 week", date_labels = "%b %d")
21+
22+
twenty_eight_days_ago = Sys.Date() - 28
23+
```
24+
25+
26+
### Coverage
27+
28+
This measures how much county coverage we have in the samples (i.e., how many unique counties are present each day), and how it has recently changed over time.
29+
30+
```{r, fig.width = 7, fig.height = 5}
31+
32+
# Sampling coverage
33+
df_usa_facts_counties = covidcast_signal(
34+
"usa-facts",
35+
"confirmed_cumulative_num",
36+
start_day = twenty_eight_days_ago,
37+
geo_type = "county"
38+
)
39+
counties_per_day = df_usa_facts_counties %>%
40+
group_by(time_value) %>%
41+
summarize(n = n())
42+
43+
ggplot(counties_per_day, aes(x = time_value, y = n)) +
44+
geom_line() + geom_point() + theme_bw() +
45+
labs(
46+
x = "Date",
47+
y = "Number of Counties",
48+
title = sprintf(
49+
"Unique Counties: %i, mean per day: %i",
50+
length(unique(
51+
df_usa_facts_counties$geo_value
52+
)),
53+
round(mean(counties_per_day$n))
54+
)
55+
) + date_scale
56+
```
57+
58+
## County Coverage Map
59+
60+
This visualizes the county coverage -- how frequently does each county show up in the data over the last 28 days?
61+
62+
```{r, fig.width = 10, fig.height = 8}
63+
64+
source("dashboard_functions.R")
65+
plot_28_day_frequency_county(df_usa_facts_counties)
66+
67+
```
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Many tests use hand-made reference data frames. In R < 4.0, columns like
2+
# `geo_values` and `data_source`, containing strings, are interpreted as
3+
# factors. To prevent us from having to set stringsAsFactors = FALSE in every
4+
# test case, set the option while saving the default to restore in the teardown
5+
# (in teardown-options.R).
6+
.defaultStringsAsFactors <- options(stringsAsFactors = FALSE)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# see setup-options.R
2+
options(stringsAsFactors = .defaultStringsAsFactors)

0 commit comments

Comments
 (0)