Skip to content

Commit 5b97c88

Browse files
authored
Merge pull request #155 from cmu-delphi/djm/endpointfun
Djm/endpointfun
2 parents 7f2d73a + f3db34a commit 5b97c88

40 files changed

+397
-231
lines changed

.Rbuildignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@
33
^.*\.Rproj$
44
^.*\..Rcheck$
55
^\.Rproj\.user$
6-
6+
^DEVELOPMENT\.md$
77
^doc$
88
^shiny$
99
^docs$
10-
^Meta$
1110
^_pkgdown\.yml$
1211
^pkgdown$
1312
^data-raw$

.github/workflows/ci.yml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,21 @@ on:
77
jobs:
88
build:
99
runs-on: ubuntu-20.04
10+
env:
11+
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
12+
R_KEEP_PKG_SOURCE: yes
1013
steps:
1114
- uses: actions/checkout@v3
1215

1316
- uses: r-lib/actions/setup-r@v2
1417
with:
1518
use-public-rspm: true
16-
r-version: 4.0
17-
18-
- uses: r-lib/actions/setup-pandoc@v2
1919

2020
- uses: r-lib/actions/setup-r-dependencies@v2
2121
with:
22-
extra-packages: any::devtools, any::rcmdcheck, local::.
22+
extra-packages: any::rcmdcheck
23+
needs: check
2324

2425
- uses: r-lib/actions/check-r-package@v2
2526
env:
2627
DELPHI_EPIDATA_KEY: ${{ secrets.SECRET_EPIPROCESS_GHACTIONS_DELPHI_EPIDATA_KEY }}
27-
with:
28-
args: 'c("--no-manual", "--as-cran")'
29-
error-on: '"error"'

vignettes/development.rmd renamed to DEVELOPMENT.md

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,3 @@
1-
---
2-
title: "Notes for Developers"
3-
output: rmarkdown::html_vignette
4-
vignette: >
5-
%\VignetteIndexEntry{Notes for Developers}
6-
%\VignetteEngine{knitr::rmarkdown}
7-
%\VignetteEncoding{UTF-8}
8-
---
9-
10-
```{r setup, include = FALSE}
11-
knitr::opts_chunk$set(
12-
collapse = TRUE,
13-
comment = "#>"
14-
)
15-
```
16-
171
## Development Environment
182

193
Relevant R commands

Meta/vignette.rds

-244 Bytes
Binary file not shown.

NAMESPACE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ S3method(print,covidcast_data_signal)
66
S3method(print,covidcast_data_source)
77
S3method(print,epidata_call)
88
export("%>%")
9+
export(avail_endpoints)
910
export(covid_hosp_facility)
1011
export(covid_hosp_facility_lookup)
1112
export(covid_hosp_state_timeseries)

R/avail_endpoints.R

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#' List all available endpoints
2+
#'
3+
#' @return A [`tibble::tibble`] with 2 columns. `Endpoint` contains the function
4+
#' for accessing the Delphi Epidata API endpoint along with a `Description`.
5+
#' @export
6+
#'
7+
#' @examples
8+
#' endps <- avail_endpoints()
9+
#' print(endps, n = nrow(endps))
10+
avail_endpoints <- function() {
11+
h <- help.search("endpoint",
12+
package = "epidatr", fields = "concept",
13+
agrep = FALSE
14+
)$matches
15+
tib <- tibble::tibble( # printing is much nicer than data.frame
16+
Endpoint = paste0(h$Name, "()"),
17+
Description = h$Title
18+
)
19+
tib
20+
}

R/covidcast.R

Lines changed: 51 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -61,32 +61,34 @@ parse_source <- function(source, base_url) {
6161

6262
#' @method as.data.frame covidcast_data_signal_list
6363
#' @export
64-
as.data.frame.covidcast_data_signal_list <- function(signals, ...) {
65-
as.data.frame(do.call(rbind, lapply(signals, function(x) {
66-
sub <- x[c(
67-
"source",
68-
"signal",
69-
"name",
70-
"active",
71-
"short_description",
72-
"description",
73-
"time_type",
74-
"time_label",
75-
"value_label",
76-
"format",
77-
"category",
78-
"high_values_are",
79-
"is_smoothed",
80-
"is_weighted",
81-
"is_cumulative",
82-
"has_stderr",
83-
"has_sample_size"
84-
)]
85-
sub$geo_types <- paste0(names(x$geo_types), collapse = ",")
86-
sub
87-
})), row.names = sapply(signals, function(x) {
88-
x$key
89-
}), ...)
64+
as.data.frame.covidcast_data_signal_list <- function(x, ...) {
65+
as.data.frame(
66+
do.call(rbind, lapply(x, function(z) {
67+
sub <- z[c(
68+
"source",
69+
"signal",
70+
"name",
71+
"active",
72+
"short_description",
73+
"description",
74+
"time_type",
75+
"time_label",
76+
"value_label",
77+
"format",
78+
"category",
79+
"high_values_are",
80+
"is_smoothed",
81+
"is_weighted",
82+
"is_cumulative",
83+
"has_stderr",
84+
"has_sample_size"
85+
)]
86+
sub$geo_types <- paste0(names(z$geo_types), collapse = ",")
87+
sub
88+
})),
89+
row.names = sapply(x, function(y) y$key),
90+
...
91+
)
9092
}
9193

9294
#' @export
@@ -152,18 +154,29 @@ covidcast_epidata <- function(base_url = global_base_url, timeout_seconds = 30)
152154

153155
#' @method as.data.frame covidcast_data_source_list
154156
#' @export
155-
as.data.frame.covidcast_data_source_list <- function(sources, ...) {
156-
as.data.frame(do.call(rbind, lapply(sources, function(x) {
157-
sub <- x[c(
158-
"source", "name", "description", "reference_signal", "license"
159-
)]
160-
sub$signals <- paste0(sapply(x$signals, function(y) {
161-
y$signal
162-
}), collapse = ",")
163-
sub
164-
})), row.names = sapply(sources, function(x) {
165-
x$source
166-
}), ...)
157+
as.data.frame.covidcast_data_source_list <- function(x, ...) {
158+
as.data.frame(
159+
do.call(
160+
rbind,
161+
lapply(
162+
x,
163+
FUN = function(z) {
164+
cols <- c(
165+
"source", "name", "description", "reference_signal",
166+
"license"
167+
)
168+
sub <- z[cols]
169+
sub$signals <- paste0(
170+
sapply(z$signals, function(y) y$signal),
171+
collapse = ","
172+
)
173+
sub
174+
}
175+
)
176+
),
177+
row.names = sapply(x, function(z) z$source),
178+
...
179+
)
167180
}
168181

169182
print.covidcast_epidata <- function(x, ...) {

0 commit comments

Comments
 (0)