diff --git a/README.md b/README.md index e94923272..0bfae9ebb 100644 --- a/README.md +++ b/README.md @@ -83,6 +83,7 @@ As an alternative you can use Docker and Docker Compose: 1. `docker-compose up -d` to create a docker container for the current environment. 1. `docker-compose exec r bash` to jump into the container. 1. `micromamba activate www-main` to activate the environment +2. `export API_KEY=y0urAp1kEy` to add your own api key as env variable. Now you have the environment ready to start converting .Rmd blog files to html. #### Commands diff --git a/content/blog/2020-08-26-fb-survey.Rmd b/content/blog/2020-08-26-fb-survey.Rmd index 598ba02cc..0a49d9489 100644 --- a/content/blog/2020-08-26-fb-survey.Rmd +++ b/content/blog/2020-08-26-fb-survey.Rmd @@ -47,9 +47,6 @@ output: toc: true --- -```{r, echo=FALSE} -options(covidcast.auth = Sys.getenv("API_KEY")) -``` Since April 2020, in collaboration with Facebook, partner universities, and public health officials, @@ -140,6 +137,8 @@ library(covidcast) library(dplyr) library(gridExtra) +options(covidcast.auth = Sys.getenv("API_KEY")) # for more on API keys, see: https://cmu-delphi.github.io/delphi-epidata/api/api_keys.html + # Fetch Facebook % CLI signal and JHU confirmed case incidence proportion at # the state level start_day = "2020-06-15" diff --git a/content/blog/2020-08-26-fb-survey.html b/content/blog/2020-08-26-fb-survey.html index 0516c82b5..758fb7b4d 100644 --- a/content/blog/2020-08-26-fb-survey.html +++ b/content/blog/2020-08-26-fb-survey.html @@ -47,20 +47,19 @@ toc: true --- -
library(covidcast)
library(dplyr)
+options(covidcast.auth = Sys.getenv("API_KEY")) # for more on API keys, see: https://cmu-delphi.github.io/delphi-epidata/api/api_keys.html
query_date <- "2020-08-01"
covidcast_signal(
data_source = "quidel",
@@ -294,182 +294,7 @@ Tracking Observations and Revisions
knitr::kable("html", digits = 2,
col.names = c("Test date", "Positivity rate (%)", "Sample size",
"Issued on", "Lag (days)"))
--Test date - | --Positivity rate (%) - | --Sample size - | --Issued on - | --Lag (days) - | -
---|---|---|---|---|
-2020-08-01 - | --1.01 - | --198 - | --2020-08-06 - | --5 - | -
-2020-08-01 - | --0.97 - | --206 - | --2020-08-07 - | --6 - | -
-2020-08-01 - | --1.41 - | --284 - | --2020-08-10 - | --9 - | -
-2020-08-01 - | --1.38 - | --290 - | --2020-08-12 - | --11 - | -
-2020-08-01 - | --1.33 - | --377 - | --2020-08-16 - | --15 - | -
-2020-08-01 - | --1.53 - | --459 - | --2020-08-19 - | --18 - | -
-2020-08-01 - | --1.47 - | --477 - | --2020-08-20 - | --19 - | -
-2020-08-01 - | --1.46 - | --479 - | --2020-08-26 - | --25 - | -
-2020-08-01 - | --1.36 - | --513 - | --2020-08-30 - | --29 - | -
November 2023 update: Quidel data is no longer publicly available, so the table generated by the code chunk above has been removed.
Many data sources are subject to revisions:
library(covidcast)
+options(covidcast.auth = Sys.getenv("API_KEY")) # for more on API keys, see: https://cmu-delphi.github.io/delphi-epidata/api/api_keys.html
hosp <- covidcast_signal(
data_source = "hospital-admissions", signal = "smoothed_adj_covid19_from_claims",
start_day = "2020-03-01", end_day = "2020-08-30",
@@ -553,14 +379,17 @@ Accessing the API
According to the {{< apireflink "api/covidcast-signals/fb-survey.html" "relevant documentation page" >}},
this is the fb-survey
data source’s smoothed_hh_cmnty_cli
signal.
(Click the “Code” button to see the Python code used to produce this example.)
-import covidcast
+import matplotlib.pyplot as plt
+import covidcast
from datetime import date
-import matplotlib.pyplot as plt
+import os
+
+covidcast.use_api_key(os.environ['API_KEY']) # for more on API keys, see: https://cmu-delphi.github.io/delphi-epidata/api/api_keys.html
data = covidcast.signal("fb-survey", "smoothed_hh_cmnty_cli",
date(2020, 9, 8), date(2020, 9, 8),
geo_type="state")
-covidcast.plot_choropleth(data, figsize=(7, 5))
+covidcast.plot(data, plot_type="choropleth", figsize=(7, 5))
plt.title("% who know someone who is sick, Sept 8, 2020")

Each package’s documentation gives numerous other examples of pulling, plotting,
diff --git a/content/blog/2020-09-18-google-survey.Rmd b/content/blog/2020-09-18-google-survey.Rmd
index 786d01e29..bf1c001ac 100644
--- a/content/blog/2020-09-18-google-survey.Rmd
+++ b/content/blog/2020-09-18-google-survey.Rmd
@@ -145,6 +145,8 @@ library(dplyr)
library(ggplot2)
library(gridExtra)
+options(covidcast.auth = Sys.getenv("API_KEY")) # for more on API keys, see: https://cmu-delphi.github.io/delphi-epidata/api/api_keys.html
+
# Fetch county-level Google and Facebook % CLI-in-community signals, and JHU
# confirmed case incidence proportion
df_go = covidcast_signal("google-survey", "smoothed_cli", geo_type = "state")
diff --git a/content/blog/2020-09-18-google-survey.html b/content/blog/2020-09-18-google-survey.html
index e69f86665..092e38d3a 100644
--- a/content/blog/2020-09-18-google-survey.html
+++ b/content/blog/2020-09-18-google-survey.html
@@ -40,14 +40,13 @@
toc: true
---
-
@@ -138,6 +137,8 @@ CLI-in-Community
library(ggplot2)
library(gridExtra)
+options(covidcast.auth = Sys.getenv("API_KEY")) # for more on API keys, see: https://cmu-delphi.github.io/delphi-epidata/api/api_keys.html
+
# Fetch county-level Google and Facebook % CLI-in-community signals, and JHU
# confirmed case incidence proportion
df_go = covidcast_signal("google-survey", "smoothed_cli", geo_type = "state")
@@ -195,7 +196,7 @@ CLI-in-Community
In both plots, we see a reassuring trend,
but the trend on the left is noticeably stronger.
Indeed, the correlation here between the Google signal and case rates is
-0.84,
+0.83,
while that between the Facebook signal and case rates is
0.64.
To be fair, we should note that the Google signal comprises a much
@@ -330,7 +331,7 @@
Google Survey Redux
or manually (in collaboration with partners in public health and/or data
journalists). Stay tuned to the Delphi blog for updates.
-
+
In the survey methodology literature, a “proxy question” is one in which
diff --git a/content/blog/2020-10-06-survey-wave-4.Rmd b/content/blog/2020-10-06-survey-wave-4.Rmd
index daa9df4d2..2c4a63bb4 100644
--- a/content/blog/2020-10-06-survey-wave-4.Rmd
+++ b/content/blog/2020-10-06-survey-wave-4.Rmd
@@ -30,9 +30,6 @@ output:
blogdown::html_page:
toc: true
---
-```{r, echo=FALSE}
-options(covidcast.auth = Sys.getenv("API_KEY"))
-```
Beginning in early April 2020, the `r blogdown::shortcode_html("reflink", "/", "Delphi group")` has
conducted a major survey to track COVID-19 across the United States. With the
support of Facebook Data for Good, we have been able to recruit tens of
@@ -95,6 +92,8 @@ version is Wave 4.
```{r sample-size, message=FALSE, include=FALSE}
library(covidcast)
+options(covidcast.auth = Sys.getenv("API_KEY")) # for more on API keys, see: https://cmu-delphi.github.io/delphi-epidata/api/api_keys.html
+
start_day <- "2020-09-08"
end_day <- "2020-10-07"
@@ -129,12 +128,14 @@ their local community who is sick (with a fever and at least one other symptom,
such as cough or difficulty breathing). This percentage `r blogdown::shortcode_html("reflink", "2020-08-26-fb-survey#some-interesting-examples", "correlates very well")`
with COVID case rates as reported by state agencies.
-```{r mask-wearing, message=FALSE, fig.width=9, out.extra = 'class="wide-figure"'}
+```{r mask-wearing, warning=FALSE, message=FALSE, fig.width=9, out.extra = 'class="wide-figure"'}
library(covidcast)
library(ggplot2)
library(grid)
library(gridExtra)
+options(covidcast.auth = Sys.getenv("API_KEY")) # for more on API keys, see: https://cmu-delphi.github.io/delphi-epidata/api/api_keys.html
+
start_day <- "2020-09-08"
end_day <- "2020-10-07"
diff --git a/content/blog/2020-10-06-survey-wave-4.html b/content/blog/2020-10-06-survey-wave-4.html
index 96ec4092e..558240472 100644
--- a/content/blog/2020-10-06-survey-wave-4.html
+++ b/content/blog/2020-10-06-survey-wave-4.html
@@ -31,24 +31,23 @@
toc: true
---
-
-
+
@@ -130,6 +129,8 @@ Mask Wearing
library(grid)
library(gridExtra)
+options(covidcast.auth = Sys.getenv("API_KEY")) # for more on API keys, see: https://cmu-delphi.github.io/delphi-epidata/api/api_keys.html
+
start_day <- "2020-09-08"
end_day <- "2020-10-07"
@@ -224,8 +225,8 @@ Mask Wearing
"autoScale2d", "toggleSpikelines",
"hoverCompareCartesian",
"hoverClosestCartesian"))
-
-
+
+
The relationship is striking. (Hover over or click each point to see which state
it is.) Of course, correlation is not causation, and there are many differences
between these states beyond their use of masks. For example, people in more
diff --git a/content/blog/2020-10-14-dv-signal.Rmd b/content/blog/2020-10-14-dv-signal.Rmd
index 4b33409fb..ff8eb2d0f 100644
--- a/content/blog/2020-10-14-dv-signal.Rmd
+++ b/content/blog/2020-10-14-dv-signal.Rmd
@@ -75,7 +75,8 @@ library(covidcast)
library(dplyr)
library(ggplot2)
library(gridExtra)
-options(covidcast.auth = Sys.getenv("API_KEY"))
+
+options(covidcast.auth = Sys.getenv("API_KEY")) # for more on API keys, see: https://cmu-delphi.github.io/delphi-epidata/api/api_keys.html
# Fetch DV % CLI signal and USAFacts confirmed case incidence proportion at
# the state level
diff --git a/content/blog/2020-10-14-dv-signal.html b/content/blog/2020-10-14-dv-signal.html
index afefcef56..566539f92 100644
--- a/content/blog/2020-10-14-dv-signal.html
+++ b/content/blog/2020-10-14-dv-signal.html
@@ -28,17 +28,16 @@
toc: true
---
-
@@ -73,6 +72,8 @@ The Doctor Visits Indicator
library(ggplot2)
library(gridExtra)
+options(covidcast.auth = Sys.getenv("API_KEY")) # for more on API keys, see: https://cmu-delphi.github.io/delphi-epidata/api/api_keys.html
+
# Fetch DV % CLI signal and USAFacts confirmed case incidence proportion at
# the state level
start_day = "2020-04-15"
diff --git a/content/blog/2020-12-10-masks-public.Rmd b/content/blog/2020-12-10-masks-public.Rmd
index e98b0825e..a4be2115f 100644
--- a/content/blog/2020-12-10-masks-public.Rmd
+++ b/content/blog/2020-12-10-masks-public.Rmd
@@ -21,9 +21,6 @@ output:
toc: true
---
-```{r, echo=FALSE}
-options(covidcast.auth = Sys.getenv("API_KEY"))
-```
As COVID cases and deaths continue to rise in the United States, we are
repeatedly reminded that unless we take the appropriate precautions---by wearing
@@ -77,12 +74,14 @@ District of Columbia, Massachusetts, and New York), mask usage is among the
highest in the country; in the other three (South Dakota, Idaho, and Wyoming),
it's among the lowest.
-```{r state_masks_time, message=FALSE}
+```{r state_masks_time, message=FALSE, warning=FALSE}
library(covidcast)
library(dplyr)
library(ggplot2)
library(directlabels)
+options(covidcast.auth = Sys.getenv("API_KEY")) # for more on API keys, see: https://cmu-delphi.github.io/delphi-epidata/api/api_keys.html
+
states_of_interest <- c("dc", "ma", "ny", "wy", "sd", "id")
state_masks <- covidcast_signal(
@@ -118,7 +117,7 @@ states---might make you wonder: If mask usage is over 80% in most states and
over 90% in many, why does the rate of new COVID cases in the United States
currently look like this?
-```{r national_cases_time, message=FALSE}
+```{r national_cases_time, message=FALSE, warning=FALSE}
cases <- covidcast_signal(
"indicator-combination", "confirmed_7dav_incidence_num",
start_day = "2020-09-15", end_day = "2020-12-05",
@@ -222,7 +221,7 @@ mask use.
Let's see how the data looks. We'll plot the percentage of people answering
"all" or "most" to each mask question in each state:
-```{r mask_questions_compared, message=FALSE}
+```{r mask_questions_compared, message=FALSE, warning=FALSE}
masked <- covidcast_signal(
"fb-survey", "smoothed_wwearing_mask",
start_day = "2020-12-01", end_day = "2020-12-01",
@@ -332,7 +331,7 @@ is "Spent time with someone who isn't currently staying with you"; whether this
is done with a mask or not, it represents a higher risk. And the data shows that
it's done more often in states where fewer people report wearing masks:
-```{r social_distancing, message=FALSE}
+```{r social_distancing, message=FALSE, warning=FALSE}
spent_time <- covidcast_signal(
"fb-survey", "smoothed_wspent_time_1d",
start_day = "2020-12-01", end_day = "2020-12-01",
@@ -358,7 +357,7 @@ cell phone location data. Using [state-level aggregates from our
API](https://cmu-delphi.github.io/delphi-epidata/api/covidcast-signals/safegraph.html#safegraph-weekly-patterns),
we can compare mask use to the proportion of people visiting restaurants in each state:
-```{r restaurants, message=FALSE}
+```{r restaurants, message=FALSE, warning=FALSE}
# 2020-11-29 was most recent data available at time of writing
restaurants <- covidcast_signal(
"safegraph", "restaurants_visit_prop",
diff --git a/content/blog/2020-12-10-masks-public.html b/content/blog/2020-12-10-masks-public.html
index af9e6aaf2..8ffae23fc 100644
--- a/content/blog/2020-12-10-masks-public.html
+++ b/content/blog/2020-12-10-masks-public.html
@@ -21,15 +21,14 @@
toc: true
---
-
-- Studying Mask Use with Surveys
-- Addressing Potential Survey Biases
-- A Probabilistic Argument for Mask Use
-- Public Activities, Social Distancing, and Masks
-- More Opportunities in Survey Data
+- Studying Mask Use with Surveys
+- Addressing Potential Survey Biases
+- A Probabilistic Argument for Mask Use
+- Public Activities, Social Distancing, and Masks
+- More Opportunities in Survey Data
@@ -82,6 +81,8 @@ Studying Mask Use with Surveys
library(ggplot2)
library(directlabels)
+options(covidcast.auth = Sys.getenv("API_KEY")) # for more on API keys, see: https://cmu-delphi.github.io/delphi-epidata/api/api_keys.html
+
states_of_interest <- c("dc", "ma", "ny", "wy", "sd", "id")
state_masks <- covidcast_signal(
diff --git a/content/blog/2021-01-15-causal-effect-mobility.Rmd b/content/blog/2021-01-15-causal-effect-mobility.Rmd
index 12693f77b..762b0f5d0 100644
--- a/content/blog/2021-01-15-causal-effect-mobility.Rmd
+++ b/content/blog/2021-01-15-causal-effect-mobility.Rmd
@@ -27,9 +27,6 @@ output:
toc: true
---
-```{r, echo=FALSE}
-options(covidcast.auth = Sys.getenv("API_KEY"))
-```
```{r setup, include=FALSE}
knitr::opts_chunk$set(collapse = TRUE)
@@ -401,13 +398,15 @@ weekly deaths and mobility
starting February 15, 2020,
for a few states:
-```{r deaths-by-state, message=FALSE}
+```{r deaths-by-state, message=FALSE, warning=FALSE}
library(covidcast)
library(directlabels)
library(dplyr)
library(lubridate)
library(ggplot2)
+options(covidcast.auth = Sys.getenv("API_KEY")) # for more on API keys, see: https://cmu-delphi.github.io/delphi-epidata/api/api_keys.html
+
# Top 5 most populated states according to
# https://en.wikipedia.org/wiki/List_of_states_and_territories_of_the_United_States_by_population
states_of_interest <- c("ca", "tx", "fl", "ny", "pa")
diff --git a/content/blog/2021-01-15-causal-effect-mobility.html b/content/blog/2021-01-15-causal-effect-mobility.html
index 29c338366..940b636c6 100644
--- a/content/blog/2021-01-15-causal-effect-mobility.html
+++ b/content/blog/2021-01-15-causal-effect-mobility.html
@@ -27,14 +27,13 @@
toc: true
---
-
@@ -369,6 +368,8 @@ The Data and the Results
library(lubridate)
library(ggplot2)
+options(covidcast.auth = Sys.getenv("API_KEY")) # for more on API keys, see: https://cmu-delphi.github.io/delphi-epidata/api/api_keys.html
+
# Top 5 most populated states according to
# https://en.wikipedia.org/wiki/List_of_states_and_territories_of_the_United_States_by_population
states_of_interest <- c("ca", "tx", "fl", "ny", "pa")
diff --git a/content/blog/2021-01-22-holiday-surveys.Rmd b/content/blog/2021-01-22-holiday-surveys.Rmd
index 630aabb92..9607f22d8 100644
--- a/content/blog/2021-01-22-holiday-surveys.Rmd
+++ b/content/blog/2021-01-22-holiday-surveys.Rmd
@@ -29,9 +29,6 @@ output:
blogdown::html_page:
toc: true
---
-```{r, echo=FALSE}
-options(covidcast.auth = Sys.getenv("API_KEY"))
-```
With pandemic fatigue setting in across the United States after a long year
filled with uncertainty, many felt the temptation to celebrate a “normal”
Thanksgiving and Christmas. However, with cases steeply rising across the US,
@@ -70,7 +67,7 @@ from airlines suggested that travel reached its highest levels since the start
of the pandemic during the Christmas holiday with about 1% of the US population
taking flights in just the few days surrounding the holiday.
-```{r traveled-recently, message=FALSE, fig.width=9, out.extra = 'class="wide-figure"'}
+```{r traveled-recently, warning=FALSE, message=FALSE, fig.width=9, out.extra = 'class="wide-figure"'}
library(covidcast)
library(ggplot2)
library(stringr)
@@ -78,6 +75,8 @@ library(dplyr)
library(grid)
library(gridExtra)
+options(covidcast.auth = Sys.getenv("API_KEY")) # for more on API keys, see: https://cmu-delphi.github.io/delphi-epidata/api/api_keys.html
+
start_after_election <- "2020-11-10"
end_day <- "2021-01-05"
diff --git a/content/blog/2021-01-22-holiday-surveys.html b/content/blog/2021-01-22-holiday-surveys.html
index 1e36afc43..5930262bc 100644
--- a/content/blog/2021-01-22-holiday-surveys.html
+++ b/content/blog/2021-01-22-holiday-surveys.html
@@ -30,13 +30,12 @@
toc: true
---
-
@@ -82,6 +81,8 @@ Travel and Other Social Behaviors During US Holidays
library(grid)
library(gridExtra)
+options(covidcast.auth = Sys.getenv("API_KEY")) # for more on API keys, see: https://cmu-delphi.github.io/delphi-epidata/api/api_keys.html
+
start_after_election <- "2020-11-10"
end_day <- "2021-01-05"
@@ -114,7 +115,7 @@ Travel and Other Social Behaviors During US Holidays
filter(geo_value %in% str_to_lower(statelist)) %>%
mutate(value = plyr::mapvalues(geo_value, str_to_lower(statelist), regions),
value = as.integer(factor(value)))
-
+attr(regionmap, "metadata") <- list(geo_type = "state")
grid_label <- textGrob("Data from Delphi COVIDcast, delphi.cmu.edu",
hjust = 1, x = 1, gp = gpar(fontsize = 9))
diff --git a/content/blog/_2021-04-20-jj-vaccine.Rmd b/content/blog/_2021-04-20-jj-vaccine.Rmd
index e91a4ebc4..a3afa0fff 100644
--- a/content/blog/_2021-04-20-jj-vaccine.Rmd
+++ b/content/blog/_2021-04-20-jj-vaccine.Rmd
@@ -41,6 +41,8 @@ library(ggplot2)
library(scales)
library(gt)
+options(covidcast.auth = Sys.getenv("API_KEY")) # for more on API keys, see: https://cmu-delphi.github.io/delphi-epidata/api/api_keys.html
+
knitr::opts_chunk$set(echo = FALSE)
dfs <- lapply(list.files("jj-data/", "*.csv.gz$", include.dirs = TRUE),
diff --git a/environment.yml b/environment.yml
index a5df8c737..eb4776646 100644
--- a/environment.yml
+++ b/environment.yml
@@ -62,4 +62,4 @@ dependencies:
- matplotlib
- udunits2
- pip:
- - covidcast==0.1.3
+ - covidcast
diff --git a/static/blog/2020-08-28-api_files/figure-html/python-data-1.svg b/static/blog/2020-08-28-api_files/figure-html/python-data-1.svg
index 38cd0768b..7696fc6ee 100644
--- a/static/blog/2020-08-28-api_files/figure-html/python-data-1.svg
+++ b/static/blog/2020-08-28-api_files/figure-html/python-data-1.svg
@@ -1,24 +1,23 @@
-
-