@@ -149,22 +149,23 @@ df_in = covidcast_signal("jhu-csse", "confirmed_7dav_incidence_prop",
149149df_fb_avg = df_fb %>% group_by(geo_value) %>% summarize(value = mean(value))
150150df_in_avg = df_in %>% group_by(geo_value) %>% summarize(value = mean(value))
151151
152- # Set a bunch of fields so that the data frames know how to plot themselves
153- df_fb_avg$time_value = df_in_avg$time_value = start_day
154- df_fb_avg$issue = df_in_avg$issue = start_day
155- attributes(df_fb_avg)$metadata$geo_type = "state"
156- attributes(df_in_avg)$metadata$geo_type = "state"
157- class(df_fb_avg) = c("covidcast_signal", class(df_fb_avg))
158- class(df_in_avg) = c("covidcast_signal", class(df_in_avg))
152+ # Turn these into covidcast_signal data frames that can be mapped
153+ df_fb_avg = df_fb_avg %>%
154+ mutate(time_value = start_day) %>%
155+ as.covidcast_signal(signal = "fb_avg", geo_type = "state")
156+
157+ df_in_avg = df_in_avg %>%
158+ mutate(time_value = start_day) %>%
159+ as.covidcast_signal(signal = "in_avg", geo_type = "state")
159160
160161# Plot choropleth maps, using the covidcast plotting functionality
161162subtitle = paste("Averaged over", start_day, "to", end_day)
162163p1 = plot(df_fb_avg,
163164 title = "% of people with COVID symptoms, based on Facebook surveys",
164- range= c(0, 1), choro_params = list(subtitle = subtitle))
165+ range = c(0, 1), choro_params = list(subtitle = subtitle))
165166p2 = plot(df_in_avg,
166167 title = "Daily new confirmed COVID-19 cases per 100,000 people",
167- range= c(0, 30), choro_params = list(subtitle = subtitle))
168+ range = c(0, 30), choro_params = list(subtitle = subtitle))
168169grid.arrange(p1, p2, nrow = 1)
169170```
170171
@@ -539,12 +540,13 @@ or we didn't have enough data from the surveys in
539540order to estimate % CLI and % CLI-in-community signals there.
540541
541542``` {r, fig.width = 10, fig.height = 4, out.extra = 'class="wide-figure"'}
542- # Set a bunch of fields so that the data frames know how to plot themselves
543- df_cor1$time_value = df_cor2$time_value = start_day
544- df_cor1$issue = df_cor2$issue = start_day
545- attributes(df_cor1)$metadata$geo_type = "county"
546- attributes(df_cor2)$metadata$geo_type = "county"
547- class(df_cor1) = class(df_cor2) = c("covidcast_signal", "data.frame")
543+ # Use as.covidcast_signal to turn these into mappable signals
544+ df_cor1 = df_cor1 %>%
545+ mutate(time_value = start_day) %>%
546+ as.covidcast_signal(signal = "cor1")
547+ df_cor2 = df_cor2 %>%
548+ mutate(time_value = start_day) %>%
549+ as.covidcast_signal(signal = "cor1")
548550
549551# Plot choropleth maps, using the covidcast plotting functionality
550552p1 = plot(df_cor1, title = "Correlation between % CLI and case rates",
0 commit comments