From 0ab92e35d96298690c18c4b1a2659aa06b486bfc Mon Sep 17 00:00:00 2001 From: minhkhul <118945681+minhkhul@users.noreply.github.com> Date: Tue, 5 Dec 2023 12:58:53 -0500 Subject: [PATCH 1/9] 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 --- README.md | 1 + content/blog/2020-08-26-fb-survey.Rmd | 5 +- content/blog/2020-08-26-fb-survey.html | 19 +- content/blog/2020-08-28-api.Rmd | 12 +- content/blog/2020-08-28-api.html | 199 +- content/blog/2020-09-18-google-survey.Rmd | 2 + content/blog/2020-09-18-google-survey.html | 15 +- content/blog/2020-10-06-survey-wave-4.Rmd | 9 +- content/blog/2020-10-06-survey-wave-4.html | 17 +- content/blog/2020-10-14-dv-signal.Rmd | 3 +- content/blog/2020-10-14-dv-signal.html | 17 +- content/blog/2020-12-10-masks-public.Rmd | 15 +- content/blog/2020-12-10-masks-public.html | 13 +- .../2021-01-15-causal-effect-mobility.Rmd | 7 +- .../2021-01-15-causal-effect-mobility.html | 11 +- content/blog/2021-01-22-holiday-surveys.Rmd | 7 +- content/blog/2021-01-22-holiday-surveys.html | 11 +- content/blog/_2021-04-20-jj-vaccine.Rmd | 2 + environment.yml | 2 +- .../figure-html/python-data-1.svg | 5042 +++++++++-------- .../figure-html/mask-wearing-1.svg | 538 +- .../figure-html/pct-tested-1.svg | 275 +- .../figure-html/test-positivity-1.svg | 275 +- .../figure-html/wanted-test-1.svg | 275 +- .../figure-html/mask_questions_compared-1.svg | 319 +- .../figure-html/national_cases_time-1.svg | 107 +- .../figure-html/restaurants-1.svg | 211 +- .../figure-html/social_distancing-1.svg | 199 +- .../figure-html/state_masks_time-1.svg | 151 +- .../figure-html/deaths-by-state-1.svg | 135 +- .../figure-html/mobility-by-state-1.svg | 121 +- .../figure-html/spent-time-1.svg | 175 +- .../figure-html/tested-recently-1.svg | 167 +- .../figure-html/traveled-recently-1.svg | 935 +-- .../figure-html/went-shopping-1.svg | 181 +- .../figure-html/wore-mask-1.svg | 173 +- .../crosstalk/css/crosstalk.css | 27 - .../crosstalk/css/crosstalk.min.css | 1 + .../crosstalk/scss/crosstalk.scss | 75 + .../rmarkdown-libs/htmlwidgets/htmlwidgets.js | 58 +- .../rmarkdown-libs/plotly-binding/plotly.js | 30 +- .../plotly-main/plotly-latest.min.js | 68 +- 42 files changed, 4861 insertions(+), 5044 deletions(-) delete mode 100644 static/rmarkdown-libs/crosstalk/css/crosstalk.css create mode 100644 static/rmarkdown-libs/crosstalk/css/crosstalk.min.css create mode 100644 static/rmarkdown-libs/crosstalk/scss/crosstalk.scss 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 --- -
@@ -141,6 +140,8 @@

Short Background

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-28-api.Rmd b/content/blog/2020-08-28-api.Rmd index 3828a5b36..c8675d28b 100644 --- a/content/blog/2020-08-28-api.Rmd +++ b/content/blog/2020-08-28-api.Rmd @@ -282,9 +282,10 @@ and ask "What was known _as of_ this date?" This is important because estimates can change for _weeks_ as new data arrives: -```{r q-versioning, warning=FALSE, message=FALSE, cache=TRUE} +```{r q-versioning, warning=FALSE, message=FALSE, cache=TRUE, eval=FALSE} 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", @@ -300,6 +301,7 @@ covidcast_signal( col.names = c("Test date", "Positivity rate (%)", "Sample size", "Issued on", "Lag (days)")) ``` +*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: @@ -359,6 +361,7 @@ that are due to COVID-19 in several states. ```{r dv-graph, message=FALSE, cache=TRUE} 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", @@ -398,14 +401,17 @@ 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.) ```{python python-data, dev='svg'} +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") ``` diff --git a/content/blog/2020-08-28-api.html b/content/blog/2020-08-28-api.html index 5a16146ff..8866b34e8 100644 --- a/content/blog/2020-08-28-api.html +++ b/content/blog/2020-08-28-api.html @@ -51,15 +51,14 @@ toc: true --- -
@@ -280,6 +279,7 @@

Tracking Observations and Revisions

can change for weeks as new data arrives:

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: