Skip to content

Commit 8e5af40

Browse files
Factor out chorpleth plot
1 parent 53a4d38 commit 8e5af40

File tree

5 files changed

+17
-30
lines changed

5 files changed

+17
-30
lines changed

R-notebooks/dashboard_functions.R

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
plot_28_day_frequency <- function(df_to_plot, geo_type) {
2+
# These are all required for rendering using covidcast.plot
3+
df_to_plot$time_value = "2020-04-15"
4+
df_to_plot$issue = "2020-04-15"
5+
attributes(df_to_plot)$geo_type = geo_type
6+
class(df_to_plot) = c("covidcast_signal", "data.frame")
7+
8+
plot(df_to_plot, range=c(0,28))
9+
}

R-notebooks/doctor_visits_dashboard.Rmd

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,6 @@ counties_present = df_doctor_visits_counties %>%
5959
summarize(value = n()) %>% ungroup() %>%
6060
filter(substr(geo_value, 3, 5) != "000")
6161
62-
# These are all required for rendering using covidcast.plot
63-
counties_present$time_value = "2020-04-15"
64-
counties_present$issue = "2020-04-15"
65-
attributes(counties_present)$geo_type = "county"
66-
class(counties_present) = c("covidcast_signal", "data.frame")
67-
68-
plot(counties_present, title = "How frequently do counties appear in the last 28 days?")
62+
source("dashboard_functions.R")
63+
plot_28_day_frequency(counties_present, "county")
6964
```

R-notebooks/ght_dashboard.Rmd

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,6 @@ states_present = df_ght_states %>%
8787
group_by(geo_value) %>%
8888
summarize(value = n())
8989
90-
# These are all required for rendering using covidcast.plot
91-
states_present$time_value = "2020-04-15"
92-
states_present$issue = "2020-04-15"
93-
attributes(states_present)$geo_type = "state"
94-
class(states_present) = c("covidcast_signal", "data.frame")
95-
96-
plot(states_present, title = "How frequently do states appear in last 28 days?", range =
97-
c(0, 28))
90+
source("dashboard_functions.R")
91+
plot_28_day_frequency(states_present, "state")
9892
```

R-notebooks/hospital_admissions_dashboard.Rmd

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,6 @@ counties_present = df_hospital_admissions_counties %>%
6666
summarize(value = n()) %>% ungroup() %>%
6767
filter(substr(geo_value, 3, 5) != "000")
6868
69-
# These are all required for rendering using covidcast.plot
70-
counties_present$time_value = "2020-04-15"
71-
counties_present$issue = "2020-04-15"
72-
attributes(counties_present)$geo_type = "county"
73-
class(counties_present) = c("covidcast_signal", "data.frame")
74-
75-
plot(counties_present, title = "How frequently do counties appear in the last 28 days?", range =
76-
c(0, 28))
69+
source("dashboard_functions.R")
70+
plot_28_day_frequency(counties_present, "county")
7771
```

R-notebooks/quidel_dashboard.Rmd

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,6 @@ states_present = df_quidel_states %>%
8787
group_by(geo_value) %>%
8888
summarize(value = n())
8989
90-
# These are all required for rendering using covidcast.plot
91-
states_present$time_value = "2020-04-15"
92-
states_present$issue = "2020-04-15"
93-
attributes(states_present)$geo_type = "state"
94-
class(states_present) = c("covidcast_signal", "data.frame")
95-
96-
plot(states_present, title = "How frequently do states appear in last 28 days?")
90+
source("dashboard_functions.R")
91+
plot_28_day_frequency(states_present, "state")
9792
```

0 commit comments

Comments
 (0)