Skip to content

Commit 6f868d4

Browse files
authored
Merge pull request #320 from cmu-delphi/docs/r-api
Minor R package documentation & typo fixes
2 parents b529fbd + 9b12518 commit 6f868d4

File tree

6 files changed

+42
-22
lines changed

6 files changed

+42
-22
lines changed

R-packages/covidcast/R/covidcast.R

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,8 @@ COVIDCAST_BASE_URL <- 'https://api.covidcast.cmu.edu/epidata/api.php'
197197
#' geo_values = name_to_cbsa("Pittsburgh"))
198198
#' }
199199
#'
200-
#' @seealso [plot.covidcast_signal()], [`county_census`], [`msa_census`],
201-
#' [`state_census`]
200+
#' @seealso [plot.covidcast_signal()], [covidcast_signals()], [`county_census`],
201+
#' [`msa_census`], [`state_census`]
202202
#' @export
203203
#' @importFrom rlang abort
204204
#' @importFrom dplyr %>%
@@ -359,8 +359,8 @@ summary.covidcast_signal = function(object, ...) {
359359
#' @examples
360360
#' \dontrun{
361361
#' ## Fetch USAFacts confirmed cases and deaths over the same time period
362-
#' covidcast_signals("usa-facts", signal=c("confirmed_incidence_num",
363-
#' "deaths_incidence_num"),
362+
#' covidcast_signals("usa-facts", signal = c("confirmed_incidence_num",
363+
#' "deaths_incidence_num"),
364364
#' start_day = "2020-08-15", end_day = "2020-10-01")
365365
#' }
366366
#' @export

R-packages/covidcast/R/data.R

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
#'
2121
#' @source United States Census Bureau, at
2222
#' \url{https://www2.census.gov/programs-surveys/popest/datasets/2010-2019/counties/totals/co-est2019-alldata.csv}
23+
#'
24+
#' @seealso [fips_to_name()], [name_to_fips()]
2325
"county_census"
2426

2527
#' Metro area population data
@@ -50,6 +52,8 @@
5052
#'
5153
#' @source United States Census Bureau, at
5254
#' \url{https://www2.census.gov/programs-surveys/popest/datasets/2010-2019/metro/totals/cbsa-est2019-alldata.csv}
55+
#'
56+
#' @seealso [cbsa_to_name()], [name_to_cbsa()]
5357
"msa_census"
5458

5559
#' State population data
@@ -67,6 +71,8 @@
6771
#'
6872
#' @source United States Census Bureau, at
6973
#' \url{https://www2.census.gov/programs-surveys/popest/datasets/2010-2019/state/detail/SCPRC-EST2019-18+POP-RES.csv}
74+
#'
75+
#' @seealso [abbr_to_name()], [name_to_abbr()], [abbr_to_fips()], [fips_to_abbr()]
7076
"state_census"
7177

7278
#' County latitudes and longitudes

R-packages/covidcast/R/wrangle.R

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,8 @@ aggregate_signals = function(x, dt = NULL, format = c("wide", "long")) {
256256
#' `aggregate_signals()` had been called in the first place with that
257257
#' `format` argument.
258258
#'
259+
#' @seealso [covidcast_signals()]
260+
#'
259261
#' @export
260262
covidcast_longer = function(x) {
261263
if (!inherits(x, "covidcast_signal_wide")) {

R-packages/covidcast/index.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,32 @@
11
# covidcast R package
22

3-
Provides R access to the [COVIDcast
3+
Provides R access to the [COVIDcast Epidata
44
API](https://cmu-delphi.github.io/delphi-epidata/api/covidcast.html) published
55
by the [Delphi group](https://delphi.cmu.edu/) at [Carnegie Mellon
66
University](https://www.cmu.edu). This API provides daily access to a range of
77
COVID-related signals Delphi that builds and maintains, from sources like
88
symptom surveys and medical claims data, and also standard signals that we
99
simply mirror, like confirmed cases and deaths.
1010

11-
Consult the [COVIDcast API
11+
Consult the [COVIDcast Epidata API
1212
documentation](https://cmu-delphi.github.io/delphi-epidata/api/covidcast.html)
1313
for details on the data included in the API, licensing, and how to cite this
1414
data in your work. The [signals
1515
documentation](https://cmu-delphi.github.io/delphi-epidata/api/covidcast_signals.html)
1616
lists all the data sources and signals available through this API.
1717

18+
**To get started** using this package, view the Getting Started guide at
19+
`vignette("covidcast")`.
20+
21+
## Get updates
22+
1823
**You should consider subscribing to the [API mailing
1924
list](https://lists.andrew.cmu.edu/mailman/listinfo/delphi-covidcast-api)** to
2025
be notified of package updates, new data sources, corrections, and other
2126
updates.
2227

28+
## Usage terms
29+
2330
**Warning:** If you use data from the COVIDcast API to power a product,
2431
dashboard, app, or other service, please download the data you need and store it
2532
centrally rather than making API requests for every user. Our server resources
@@ -28,6 +35,3 @@ are limited and cannot support high-volume interactive use.
2835
See also the [COVIDcast Terms of
2936
Use](https://covidcast.cmu.edu/terms-of-use.html), noting that the data is a
3037
research product and not warranted for a particular purpose.
31-
32-
**To get started** using this package, view the Getting Started guide at
33-
`vignette("covidcast")`.

R-packages/covidcast/vignettes/correlation-utils.Rmd

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ The covidcast package provides some simple utilities for exploring the
1212
correlations between two signals, over space or time, which may be helpful for
1313
simple analyses and explorations of data.
1414

15-
For these examples, we'll load confirmed case and death rates. and restrict our
15+
For these examples, we'll load confirmed case and death rates, and restrict our
1616
analysis to counties with at least 500 total cases by August 15th.
1717

1818
```{r, message = FALSE}
@@ -81,18 +81,25 @@ linear relationship. The latter can be addressed using Spearman correlation,
8181
accomplished by setting `method = "spearman"` in the call to `covidcast_cor()`.
8282
Spearman correlation is highly robust and invariant to monotone transformations
8383
(it doesn't rely on any particular functional form for the dependence between
84-
two variables).
84+
two variables).
8585

86-
We might also interested in interested in how case rates associate with death
87-
rates in the *future*. Using the `dt_x` parameter in `covidcast_cor()`, we can
88-
lag case rates back any number of days we want, before calculating correlations.
86+
### Lagged correlations
87+
88+
We might also be interested in how case rates associate with death rates in the
89+
*future*. Using the `dt_x` parameter in `covidcast_cor()`, we can lag case rates
90+
back any number of days we want, before calculating correlations.
91+
92+
Here we set `dt_x = -10`. This means that `iprop_act` will be lagged by 10 days,
93+
meaning that cases on June 1st will be correlated with deaths on June 11th. (It
94+
might help to think of it this way: deaths on a certain day will be correlated
95+
with cases with an offset of -10 days.)
8996

9097
```{r, warning = FALSE}
9198
# Use Spearman correlation, with case rates and 10-day lagged case rates
9299
df_cor1 <- covidcast_cor(iprop_act, dprop_act, by = "time_value",
93-
method = "spearman")
100+
method = "spearman")
94101
df_cor2 <- covidcast_cor(iprop_act, dprop_act, by = "time_value", dt_x = -10,
95-
method = "spearman")
102+
method = "spearman")
96103
97104
# Stack rowwise into one data frame, then plot time series
98105
df_cor <- rbind(df_cor1, df_cor2)
@@ -106,10 +113,10 @@ ggplot(df_cor, aes(x = time_value, y = value)) +
106113
theme(legend.position = "bottom")
107114
```
108115

109-
We can see that, for the most part, the Spearman measure has bolstered the
110-
correlations; and generally, lagging the case rates time series back by 10 days
111-
improves correlations, confirming case rates are better correlated with death
112-
rates 10 days from now.
116+
We can see that, for the most part, the Spearman measure has bolstered the
117+
correlations; and generally, lagging the case rates back by 10 days improves
118+
correlations, confirming case rates are better correlated with death rates 10
119+
days from now.
113120

114121
## Correlations sliced by county
115122

R-packages/covidcast/vignettes/multi-signals.Rmd

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ be vectors. See the `covidcast_signals()` documentation for details.
4343
## Aggregating signals, wide format
4444

4545
To aggregate multiple signals together, we can use the `aggregate_signals()`
46-
function, which acceps a list of `covidcast_signal` objects, as returned by
46+
function, which accepts a list of `covidcast_signal` objects, as returned by
4747
`covidcast_signals()`. With all arguments set to their default values,
4848
`aggregate_signals()` returns a data frame in "wide" format:
4949

@@ -87,7 +87,8 @@ aggregate_signals(signals[[1]], dt = c(-1, 0, 1)) %>%
8787

8888
## Aggregating signals, long format
8989

90-
We can also use `aggregate_signals()` in "long" format:
90+
We can also use `aggregate_signals()` in "long" format, with one observation
91+
per row:
9192

9293
```{r}
9394
aggregate_signals(signals, format = "long") %>%

0 commit comments

Comments
 (0)