From c640cbc2acf3636b3f0150e07dfe02e35633218d Mon Sep 17 00:00:00 2001 From: dsweber2 Date: Fri, 14 Mar 2025 16:22:33 -0500 Subject: [PATCH 1/8] fixing #300 --- R/covidcast.R | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/R/covidcast.R b/R/covidcast.R index 32868499..d260ad9e 100644 --- a/R/covidcast.R +++ b/R/covidcast.R @@ -69,18 +69,14 @@ parse_source <- function(source, base_url) { #' @export as_tibble.covidcast_data_signal_list <- function(x, ...) { tib <- list() - tib$source <- unname(map_chr(x, "source")) - tib$signal <- unname(map_chr(x, "signal")) - tib$name <- unname(map_chr(x, "name")) - tib$active <- unname(map_lgl(x, "active")) - tib$short_description <- unname(map_chr(x, "short_description")) - tib$description <- unname(map_chr(x, "description")) - tib$time_type <- unname(map_chr(x, "time_type")) - tib$time_label <- unname(map_chr(x, "time_label")) - tib$value_label <- unname(map_chr(x, "value_label")) - tib$format <- unname(map_chr(x, "format")) - tib$category <- unname(map_chr(x, "category")) - tib$high_values_are <- unname(map_chr(x, "high_values_are")) + fields <- c( + "source", "signal", "name", "active", "short_description", + "description", "time_type", "time_label", "value_label", + "format", "category", "high_values_are" + ) + for (field in fields) { + tib[[field]] <- unname(map_chr(x, field, .default = "")) + } as_tibble(tib) } @@ -184,11 +180,10 @@ covidcast_epidata <- function(base_url = global_base_url, timeout_seconds = 30) #' @export as_tibble.covidcast_data_source_list <- function(x, ...) { tib <- list() - tib$source <- unname(map_chr(x, "source")) - tib$name <- unname(map_chr(x, "name")) - tib$description <- unname(map_chr(x, "description")) - tib$reference_signal <- unname(map_chr(x, "reference_signal")) - tib$license <- unname(map_chr(x, "license")) + fields <- c("source", "name", "description", "reference_signal", "license") + for (field in fields) { + tib[[field]] <- unname(map_chr(x, field, .default = "")) + } as_tibble(tib) } From 6dd72f14f5dc6bccba98e56f117749ab2629b247 Mon Sep 17 00:00:00 2001 From: dsweber2 Date: Fri, 14 Mar 2025 16:25:36 -0500 Subject: [PATCH 2/8] news+description --- DESCRIPTION | 2 +- NEWS.md | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 18b78398..ba19419e 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Type: Package Package: epidatr Title: Client for Delphi's 'Epidata' API -Version: 1.2.0 +Version: 1.2.1 Authors@R: c( person("Logan", "Brooks", , "lcbrooks@andrew.cmu.edu", role = "aut"), person("Dmitry", "Shemetov", , "dshemeto@andrew.cmu.edu", role = "aut"), diff --git a/NEWS.md b/NEWS.md index c8e837c3..f9317324 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,7 @@ +# epidatr 1.2.1 +## Patches +- Fix so that `covidcast_epidata()` will still print if fields are missing. + # epidatr 1.2.0 ## Changes From 61249038f03dee8b36dfb390d649a828fe355d9e Mon Sep 17 00:00:00 2001 From: dsweber2 Date: Fri, 14 Mar 2025 21:27:13 +0000 Subject: [PATCH 3/8] docs: document (GHA) --- man/covidcast_epidata.Rd | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/man/covidcast_epidata.Rd b/man/covidcast_epidata.Rd index e11c63b1..bdf59b75 100644 --- a/man/covidcast_epidata.Rd +++ b/man/covidcast_epidata.Rd @@ -27,7 +27,14 @@ an object containing fields for every signal: \if{html}{\out{
}}\preformatted{epidata <- covidcast_epidata() epidata$signals -#> # A tibble: 451 x 3 +#> Warning: Automatic coercion from logical to character was deprecated in purrr 1.0.0. +#> i Please use an explicit call to `as.character()` within `map_chr()` instead. +#> i The deprecated feature was likely used in the epidatr package. +#> Please report the issue at . +#> This warning is displayed once every 8 hours. +#> Call `lifecycle::last_lifecycle_warnings()` to see where this warning was +#> generated. +#> # A tibble: 468 x 3 #> source signal short_description #> #> 1 chng smoothed_outpatient_cli Estimated percentage of outpatie~ @@ -36,11 +43,11 @@ epidata$signals #> 4 chng smoothed_adj_outpatient_covid COVID-Confirmed Doctor Visits #> 5 chng smoothed_outpatient_flu Estimated percentage of outpatie~ #> 6 chng smoothed_adj_outpatient_flu Estimated percentage of outpatie~ -#> 7 covid-act-now pcr_specimen_positivity_rate Proportion of PCR specimens test~ -#> 8 covid-act-now pcr_specimen_total_tests Total number of PCR specimens te~ -#> 9 doctor-visits smoothed_cli Percentage of daily doctor visit~ -#> 10 doctor-visits smoothed_adj_cli Percentage of daily doctor visit~ -#> # i 441 more rows +#> 7 chng 7dav_inpatient_covid Ratio of inpatient hospitalizati~ +#> 8 chng 7dav_outpatient_covid Ratio of outpatient doctor visit~ +#> 9 covid-act-now pcr_specimen_positivity_rate Proportion of PCR specimens test~ +#> 10 covid-act-now pcr_specimen_total_tests Total number of PCR specimens te~ +#> # i 458 more rows }\if{html}{\out{
}} If you use an editor that supports tab completion, such as RStudio, type From 01cb82a3c4e644ed4ff40b45bcfac7daf9b754d3 Mon Sep 17 00:00:00 2001 From: dsweber2 Date: Fri, 14 Mar 2025 16:38:28 -0500 Subject: [PATCH 4/8] returns are fine actually --- .lintr | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.lintr b/.lintr index c7c90554..def0c185 100644 --- a/.lintr +++ b/.lintr @@ -1,7 +1,7 @@ linters: linters_with_defaults( line_length_linter(120), - cyclocomp_linter = NULL, - object_length_linter(length = 40L) + object_length_linter(length = 40L), + return_linter = NULL ) exclusions: list( "renv", From bb9769295faf5cc48841606fe1769e823f468e18 Mon Sep 17 00:00:00 2001 From: dsweber2 Date: Fri, 14 Mar 2025 16:40:11 -0500 Subject: [PATCH 5/8] test-coverage job update --- .github/workflows/test-coverage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-coverage.yml b/.github/workflows/test-coverage.yml index 745873b3..8884f538 100644 --- a/.github/workflows/test-coverage.yml +++ b/.github/workflows/test-coverage.yml @@ -47,7 +47,7 @@ jobs: - name: Upload test results if: failure() - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: coverage-test-failures path: ${{ runner.temp }}/package From 8310e34268eb085f0c1648ed1cac14ccd64d7027 Mon Sep 17 00:00:00 2001 From: David Weber Date: Tue, 18 Mar 2025 08:56:32 -0700 Subject: [PATCH 6/8] Update R/covidcast.R Co-authored-by: Dmitry Shemetov --- R/covidcast.R | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/R/covidcast.R b/R/covidcast.R index d260ad9e..67cdaed5 100644 --- a/R/covidcast.R +++ b/R/covidcast.R @@ -69,14 +69,18 @@ parse_source <- function(source, base_url) { #' @export as_tibble.covidcast_data_signal_list <- function(x, ...) { tib <- list() - fields <- c( - "source", "signal", "name", "active", "short_description", + chr_fields <- c( + "source", "signal", "name", "short_description", "description", "time_type", "time_label", "value_label", "format", "category", "high_values_are" ) - for (field in fields) { + for (field in chr_fields ) { tib[[field]] <- unname(map_chr(x, field, .default = "")) } + lgl_fields <- c("active") + for (field in lgl_fields ) { + tib[[field]] <- unname(map_lgl(x, field, .default = "")) + } as_tibble(tib) } From dbd4d0d6cc6374297f6438247a69976974e1b737 Mon Sep 17 00:00:00 2001 From: dsweber2 Date: Tue, 18 Mar 2025 15:58:33 +0000 Subject: [PATCH 7/8] style: styler (GHA) --- R/covidcast.R | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/R/covidcast.R b/R/covidcast.R index 67cdaed5..74c8a6f7 100644 --- a/R/covidcast.R +++ b/R/covidcast.R @@ -74,13 +74,13 @@ as_tibble.covidcast_data_signal_list <- function(x, ...) { "description", "time_type", "time_label", "value_label", "format", "category", "high_values_are" ) - for (field in chr_fields ) { + for (field in chr_fields) { tib[[field]] <- unname(map_chr(x, field, .default = "")) } lgl_fields <- c("active") - for (field in lgl_fields ) { + for (field in lgl_fields) { tib[[field]] <- unname(map_lgl(x, field, .default = "")) - } + } as_tibble(tib) } From 98fab61dbd0aa39c1edcc8f5c7a94ac93b9b7780 Mon Sep 17 00:00:00 2001 From: dsweber2 Date: Tue, 18 Mar 2025 15:58:44 +0000 Subject: [PATCH 8/8] docs: document (GHA) --- man/covidcast_epidata.Rd | 7 ------- 1 file changed, 7 deletions(-) diff --git a/man/covidcast_epidata.Rd b/man/covidcast_epidata.Rd index bdf59b75..fbf3f1cc 100644 --- a/man/covidcast_epidata.Rd +++ b/man/covidcast_epidata.Rd @@ -27,13 +27,6 @@ an object containing fields for every signal: \if{html}{\out{
}}\preformatted{epidata <- covidcast_epidata() epidata$signals -#> Warning: Automatic coercion from logical to character was deprecated in purrr 1.0.0. -#> i Please use an explicit call to `as.character()` within `map_chr()` instead. -#> i The deprecated feature was likely used in the epidatr package. -#> Please report the issue at . -#> This warning is displayed once every 8 hours. -#> Call `lifecycle::last_lifecycle_warnings()` to see where this warning was -#> generated. #> # A tibble: 468 x 3 #> source signal short_description #>