Skip to content

Commit 0ab92e3

Browse files
minhkhulmelange396
andauthored
Fix blog build (#891)
* add instruction to build blog locally with personal api key * fix quidel #887 by removing r chunk result + warn readers * upgrade python covidcast version + add api key to python chunk in blog * more api key visibility + instruction link * every R chunk that import library(covidcast) will have an associated API key + instruction link code line in that chunk * fix visuals not showing up due to warning messages * workaround render python chunk plot * generated files from rmd with changes * remove warning in blog 2021-01-15-causal-effect-mobility * remove warning 2020-12-10-masks-public --------- Co-authored-by: melange396 <[email protected]>
1 parent dc63a37 commit 0ab92e3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+4861
-5044
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ As an alternative you can use Docker and Docker Compose:
8383
1. `docker-compose up -d` to create a docker container for the current environment.
8484
1. `docker-compose exec r bash` to jump into the container.
8585
1. `micromamba activate www-main` to activate the environment
86+
2. `export API_KEY=y0urAp1kEy` to add your own api key as env variable.
8687

8788
Now you have the environment ready to start converting .Rmd blog files to html.
8889
#### Commands

content/blog/2020-08-26-fb-survey.Rmd

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,6 @@ output:
4747
toc: true
4848
---
4949

50-
```{r, echo=FALSE}
51-
options(covidcast.auth = Sys.getenv("API_KEY"))
52-
```
5350

5451
Since April 2020, in collaboration with Facebook,
5552
partner universities, and public health officials,
@@ -140,6 +137,8 @@ library(covidcast)
140137
library(dplyr)
141138
library(gridExtra)
142139
140+
options(covidcast.auth = Sys.getenv("API_KEY")) # for more on API keys, see: https://cmu-delphi.github.io/delphi-epidata/api/api_keys.html
141+
143142
# Fetch Facebook % CLI signal and JHU confirmed case incidence proportion at
144143
# the state level
145144
start_day = "2020-06-15"

content/blog/2020-08-26-fb-survey.html

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,20 +47,19 @@
4747
toc: true
4848
---
4949

50-
<script src="/rmarkdown-libs/header-attrs/header-attrs.js"></script>
5150

5251
<div id="TOC">
5352
<ul>
54-
<li><a href="#short-background">Short Background</a></li>
55-
<li><a href="#why-run-these-surveys">Why Run These Surveys?</a></li>
56-
<li><a href="#whats-in-the-survey">What’s in the Survey?</a></li>
57-
<li><a href="#some-interesting-examples">Some Interesting Examples</a></li>
58-
<li><a href="#basic-correlation-analysis">Basic Correlation Analysis</a>
53+
<li><a href="#short-background" id="toc-short-background">Short Background</a></li>
54+
<li><a href="#why-run-these-surveys" id="toc-why-run-these-surveys">Why Run These Surveys?</a></li>
55+
<li><a href="#whats-in-the-survey" id="toc-whats-in-the-survey">What’s in the Survey?</a></li>
56+
<li><a href="#some-interesting-examples" id="toc-some-interesting-examples">Some Interesting Examples</a></li>
57+
<li><a href="#basic-correlation-analysis" id="toc-basic-correlation-analysis">Basic Correlation Analysis</a>
5958
<ul>
60-
<li><a href="#correlations-sliced-by-time">Correlations Sliced by Time</a></li>
61-
<li><a href="#correlations-sliced-by-county">Correlations Sliced by County</a></li>
59+
<li><a href="#correlations-sliced-by-time" id="toc-correlations-sliced-by-time">Correlations Sliced by Time</a></li>
60+
<li><a href="#correlations-sliced-by-county" id="toc-correlations-sliced-by-county">Correlations Sliced by County</a></li>
6261
</ul></li>
63-
<li><a href="#whats-next-with-the-surveys">What’s Next with the Surveys</a></li>
62+
<li><a href="#whats-next-with-the-surveys" id="toc-whats-next-with-the-surveys">What’s Next with the Surveys</a></li>
6463
</ul>
6564
</div>
6665

@@ -141,6 +140,8 @@ <h2>Short Background</h2>
141140
library(dplyr)
142141
library(gridExtra)
143142

143+
options(covidcast.auth = Sys.getenv(&quot;API_KEY&quot;)) # for more on API keys, see: https://cmu-delphi.github.io/delphi-epidata/api/api_keys.html
144+
144145
# Fetch Facebook % CLI signal and JHU confirmed case incidence proportion at
145146
# the state level
146147
start_day = &quot;2020-06-15&quot;

content/blog/2020-08-28-api.Rmd

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -282,9 +282,10 @@ and ask "What was known _as of_ this date?"
282282
This is important because estimates
283283
can change for _weeks_ as new data arrives:
284284

285-
```{r q-versioning, warning=FALSE, message=FALSE, cache=TRUE}
285+
```{r q-versioning, warning=FALSE, message=FALSE, cache=TRUE, eval=FALSE}
286286
library(covidcast)
287287
library(dplyr)
288+
options(covidcast.auth = Sys.getenv("API_KEY")) # for more on API keys, see: https://cmu-delphi.github.io/delphi-epidata/api/api_keys.html
288289
query_date <- "2020-08-01"
289290
covidcast_signal(
290291
data_source = "quidel",
@@ -300,6 +301,7 @@ covidcast_signal(
300301
col.names = c("Test date", "Positivity rate (%)", "Sample size",
301302
"Issued on", "Lag (days)"))
302303
```
304+
*November 2023 update: Quidel data is no longer publicly available, so the table generated by the code chunk above has been removed.*
303305

304306
Many data sources are subject to revisions:
305307

@@ -359,6 +361,7 @@ that are due to COVID-19 in several states.
359361

360362
```{r dv-graph, message=FALSE, cache=TRUE}
361363
library(covidcast)
364+
options(covidcast.auth = Sys.getenv("API_KEY")) # for more on API keys, see: https://cmu-delphi.github.io/delphi-epidata/api/api_keys.html
362365
hosp <- covidcast_signal(
363366
data_source = "hospital-admissions", signal = "smoothed_adj_covid19_from_claims",
364367
start_day = "2020-03-01", end_day = "2020-08-30",
@@ -398,14 +401,17 @@ this is the `fb-survey` data source's `smoothed_hh_cmnty_cli` signal.
398401
(Click the "Code" button to see the Python code used to produce this example.)
399402

400403
```{python python-data, dev='svg'}
404+
import matplotlib.pyplot as plt
401405
import covidcast
402406
from datetime import date
403-
import matplotlib.pyplot as plt
407+
import os
408+
409+
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
404410
405411
data = covidcast.signal("fb-survey", "smoothed_hh_cmnty_cli",
406412
date(2020, 9, 8), date(2020, 9, 8),
407413
geo_type="state")
408-
covidcast.plot_choropleth(data, figsize=(7, 5))
414+
covidcast.plot(data, plot_type="choropleth", figsize=(7, 5))
409415
plt.title("% who know someone who is sick, Sept 8, 2020")
410416
```
411417

content/blog/2020-08-28-api.html

Lines changed: 14 additions & 185 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,14 @@
5151
toc: true
5252
---
5353

54-
<script src="/rmarkdown-libs/header-attrs/header-attrs.js"></script>
5554

5655
<div id="TOC">
5756
<ul>
58-
<li><a href="#purpose-of-the-api">Purpose of the API</a></li>
59-
<li><a href="#unique-data-sources">Unique Data Sources</a></li>
60-
<li><a href="#tracking-observations-and-revisions">Tracking Observations and Revisions</a></li>
61-
<li><a href="#accessing-the-api">Accessing the API</a></li>
62-
<li><a href="#putting-the-api-to-work">Putting the API to Work</a></li>
57+
<li><a href="#purpose-of-the-api" id="toc-purpose-of-the-api">Purpose of the API</a></li>
58+
<li><a href="#unique-data-sources" id="toc-unique-data-sources">Unique Data Sources</a></li>
59+
<li><a href="#tracking-observations-and-revisions" id="toc-tracking-observations-and-revisions">Tracking Observations and Revisions</a></li>
60+
<li><a href="#accessing-the-api" id="toc-accessing-the-api">Accessing the API</a></li>
61+
<li><a href="#putting-the-api-to-work" id="toc-putting-the-api-to-work">Putting the API to Work</a></li>
6362
</ul>
6463
</div>
6564

@@ -280,6 +279,7 @@ <h2>Tracking Observations and Revisions</h2>
280279
can change for <em>weeks</em> as new data arrives:</p>
281280
<pre class="r"><code>library(covidcast)
282281
library(dplyr)
282+
options(covidcast.auth = Sys.getenv(&quot;API_KEY&quot;)) # for more on API keys, see: https://cmu-delphi.github.io/delphi-epidata/api/api_keys.html
283283
query_date &lt;- &quot;2020-08-01&quot;
284284
covidcast_signal(
285285
data_source = &quot;quidel&quot;,
@@ -294,182 +294,7 @@ <h2>Tracking Observations and Revisions</h2>
294294
knitr::kable(&quot;html&quot;, digits = 2,
295295
col.names = c(&quot;Test date&quot;, &quot;Positivity rate (%)&quot;, &quot;Sample size&quot;,
296296
&quot;Issued on&quot;, &quot;Lag (days)&quot;))</code></pre>
297-
<table>
298-
<thead>
299-
<tr>
300-
<th style="text-align:left;">
301-
Test date
302-
</th>
303-
<th style="text-align:right;">
304-
Positivity rate (%)
305-
</th>
306-
<th style="text-align:right;">
307-
Sample size
308-
</th>
309-
<th style="text-align:left;">
310-
Issued on
311-
</th>
312-
<th style="text-align:right;">
313-
Lag (days)
314-
</th>
315-
</tr>
316-
</thead>
317-
<tbody>
318-
<tr>
319-
<td style="text-align:left;">
320-
2020-08-01
321-
</td>
322-
<td style="text-align:right;">
323-
1.01
324-
</td>
325-
<td style="text-align:right;">
326-
198
327-
</td>
328-
<td style="text-align:left;">
329-
2020-08-06
330-
</td>
331-
<td style="text-align:right;">
332-
5
333-
</td>
334-
</tr>
335-
<tr>
336-
<td style="text-align:left;">
337-
2020-08-01
338-
</td>
339-
<td style="text-align:right;">
340-
0.97
341-
</td>
342-
<td style="text-align:right;">
343-
206
344-
</td>
345-
<td style="text-align:left;">
346-
2020-08-07
347-
</td>
348-
<td style="text-align:right;">
349-
6
350-
</td>
351-
</tr>
352-
<tr>
353-
<td style="text-align:left;">
354-
2020-08-01
355-
</td>
356-
<td style="text-align:right;">
357-
1.41
358-
</td>
359-
<td style="text-align:right;">
360-
284
361-
</td>
362-
<td style="text-align:left;">
363-
2020-08-10
364-
</td>
365-
<td style="text-align:right;">
366-
9
367-
</td>
368-
</tr>
369-
<tr>
370-
<td style="text-align:left;">
371-
2020-08-01
372-
</td>
373-
<td style="text-align:right;">
374-
1.38
375-
</td>
376-
<td style="text-align:right;">
377-
290
378-
</td>
379-
<td style="text-align:left;">
380-
2020-08-12
381-
</td>
382-
<td style="text-align:right;">
383-
11
384-
</td>
385-
</tr>
386-
<tr>
387-
<td style="text-align:left;">
388-
2020-08-01
389-
</td>
390-
<td style="text-align:right;">
391-
1.33
392-
</td>
393-
<td style="text-align:right;">
394-
377
395-
</td>
396-
<td style="text-align:left;">
397-
2020-08-16
398-
</td>
399-
<td style="text-align:right;">
400-
15
401-
</td>
402-
</tr>
403-
<tr>
404-
<td style="text-align:left;">
405-
2020-08-01
406-
</td>
407-
<td style="text-align:right;">
408-
1.53
409-
</td>
410-
<td style="text-align:right;">
411-
459
412-
</td>
413-
<td style="text-align:left;">
414-
2020-08-19
415-
</td>
416-
<td style="text-align:right;">
417-
18
418-
</td>
419-
</tr>
420-
<tr>
421-
<td style="text-align:left;">
422-
2020-08-01
423-
</td>
424-
<td style="text-align:right;">
425-
1.47
426-
</td>
427-
<td style="text-align:right;">
428-
477
429-
</td>
430-
<td style="text-align:left;">
431-
2020-08-20
432-
</td>
433-
<td style="text-align:right;">
434-
19
435-
</td>
436-
</tr>
437-
<tr>
438-
<td style="text-align:left;">
439-
2020-08-01
440-
</td>
441-
<td style="text-align:right;">
442-
1.46
443-
</td>
444-
<td style="text-align:right;">
445-
479
446-
</td>
447-
<td style="text-align:left;">
448-
2020-08-26
449-
</td>
450-
<td style="text-align:right;">
451-
25
452-
</td>
453-
</tr>
454-
<tr>
455-
<td style="text-align:left;">
456-
2020-08-01
457-
</td>
458-
<td style="text-align:right;">
459-
1.36
460-
</td>
461-
<td style="text-align:right;">
462-
513
463-
</td>
464-
<td style="text-align:left;">
465-
2020-08-30
466-
</td>
467-
<td style="text-align:right;">
468-
29
469-
</td>
470-
</tr>
471-
</tbody>
472-
</table>
297+
<p><em>November 2023 update: Quidel data is no longer publicly available, so the table generated by the code chunk above has been removed.</em></p>
473298
<p>Many data sources are subject to revisions:</p>
474299
<ul>
475300
<li>Case and death counts are frequently corrected or adjusted by authorities.</li>
@@ -520,6 +345,7 @@ <h2>Accessing the API</h2>
520345
that are due to COVID-19 in several states.
521346
(Click the “Code” button to see the R code used to produce this example.)</p>
522347
<pre class="r"><code>library(covidcast)
348+
options(covidcast.auth = Sys.getenv(&quot;API_KEY&quot;)) # for more on API keys, see: https://cmu-delphi.github.io/delphi-epidata/api/api_keys.html
523349
hosp &lt;- covidcast_signal(
524350
data_source = &quot;hospital-admissions&quot;, signal = &quot;smoothed_adj_covid19_from_claims&quot;,
525351
start_day = &quot;2020-03-01&quot;, end_day = &quot;2020-08-30&quot;,
@@ -553,14 +379,17 @@ <h2>Accessing the API</h2>
553379
According to the {{< apireflink "api/covidcast-signals/fb-survey.html" "relevant documentation page" >}},
554380
this is the <code>fb-survey</code> data source’s <code>smoothed_hh_cmnty_cli</code> signal.
555381
(Click the “Code” button to see the Python code used to produce this example.)</p>
556-
<pre class="python"><code>import covidcast
382+
<pre class="python"><code>import matplotlib.pyplot as plt
383+
import covidcast
557384
from datetime import date
558-
import matplotlib.pyplot as plt
385+
import os
386+
387+
covidcast.use_api_key(os.environ[&#39;API_KEY&#39;]) # for more on API keys, see: https://cmu-delphi.github.io/delphi-epidata/api/api_keys.html
559388

560389
data = covidcast.signal(&quot;fb-survey&quot;, &quot;smoothed_hh_cmnty_cli&quot;,
561390
date(2020, 9, 8), date(2020, 9, 8),
562391
geo_type=&quot;state&quot;)
563-
covidcast.plot_choropleth(data, figsize=(7, 5))
392+
covidcast.plot(data, plot_type=&quot;choropleth&quot;, figsize=(7, 5))
564393
plt.title(&quot;% who know someone who is sick, Sept 8, 2020&quot;)</code></pre>
565394
<p><img src="/blog/2020-08-28-api_files/figure-html/python-data-1.svg" /><!-- --></p>
566395
<p>Each package’s documentation gives numerous other examples of pulling, plotting,

content/blog/2020-09-18-google-survey.Rmd

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,8 @@ library(dplyr)
145145
library(ggplot2)
146146
library(gridExtra)
147147
148+
options(covidcast.auth = Sys.getenv("API_KEY")) # for more on API keys, see: https://cmu-delphi.github.io/delphi-epidata/api/api_keys.html
149+
148150
# Fetch county-level Google and Facebook % CLI-in-community signals, and JHU
149151
# confirmed case incidence proportion
150152
df_go = covidcast_signal("google-survey", "smoothed_cli", geo_type = "state")

0 commit comments

Comments
 (0)