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 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", 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 diff --git a/R/covidcast.R b/R/covidcast.R index 32868499..74c8a6f7 100644 --- a/R/covidcast.R +++ b/R/covidcast.R @@ -69,18 +69,18 @@ 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")) + chr_fields <- c( + "source", "signal", "name", "short_description", + "description", "time_type", "time_label", "value_label", + "format", "category", "high_values_are" + ) + 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) } @@ -184,11 +184,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) } diff --git a/man/covidcast_epidata.Rd b/man/covidcast_epidata.Rd index e11c63b1..fbf3f1cc 100644 --- a/man/covidcast_epidata.Rd +++ b/man/covidcast_epidata.Rd @@ -27,7 +27,7 @@ an object containing fields for every signal: \if{html}{\out{
}}\preformatted{epidata <- covidcast_epidata() epidata$signals -#> # A tibble: 451 x 3 +#> # A tibble: 468 x 3 #> source signal short_description #> #> 1 chng smoothed_outpatient_cli Estimated percentage of outpatie~ @@ -36,11 +36,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