Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,7 @@
^\.editorconfig$
^\.lintr$
^Makefile$

^venv$
^.venv$
^env$
^.env$
8 changes: 6 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
docs
inst/doc
/check
.Rdata
.httr-oauth
.DS_Store
venv
env
.venv
.env
.Rdata
.httr-oauth
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Imports:
readr,
MMWRweek,
rlang
RoxygenNote: 7.2.1
RoxygenNote: 7.2.3
Suggests:
knitr,
magrittr,
Expand Down
525 changes: 298 additions & 227 deletions R/endpoints.R

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions R/epidatacall.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
#' an abstraction that holds the information needed to make an epidata call
#'
#' @param endpoint the epidata endpoint to call
#' @param params the parameters to pass to the epidata endpoint
#' @param meta meta data to attach to the epidata call
#' @param only_supports_classic if true only classic format is supported
#'
#' @return an epidata_call instance
#'
create_epidata_call <- function(endpoint, params, meta = NULL,
only_supports_classic = FALSE) {
stopifnot(is.character(endpoint), length(endpoint) == 1)
Expand Down
4 changes: 2 additions & 2 deletions R/model.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#' builds a new EpiRange instances
#'
#' @param from A string or numeric that takes the form YYYYMMDD.
#' @param to A string or numeric that takes the form YYYYMMDD.
#' @param from A string or numeric that takes the form YYYYMMDD for dates or YYYYMM for epiweeks.
#' @param to A string or numeric that takes the form YYYYMMDD for dates or YYYYMM for epiweeks.
#' @return EpiRange instance
#'
#' @export
Expand Down
4 changes: 2 additions & 2 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ format_item <- function(value) {
"from" %in% names(value) && "to" %in% names(value) && length(names(value)) == 2) {
paste0(toString(value$from), "-", toString(value$to))
} else {
toString(value)
paste(value, collapse = ",")
}
}

Expand All @@ -16,5 +16,5 @@ format_list <- function(values) {
("from" %in% names(values) && "to" %in% names(values))) {
values <- list(values)
}
paste(sapply(values, format_item), collapse = ",")
paste(vapply(values, format_item, character(1L)), collapse = ",")
}
3 changes: 3 additions & 0 deletions tests/testthat/test-utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ test_that("format_list", {
expect_equal(format_list(5), "5")
expect_equal(format_list("5"), "5")
expect_equal(format_list(list(from = 2, to = 5)), "2-5")
expect_equal(format_list(list(list(from = 2, to = 6))), "2-6")
expect_equal(format_list(epirange(2, 8)), "2-8")
expect_equal(format_list(list(epirange(2, 9))), "2-9")
expect_equal(format_list(list("5", "4")), "5,4")
expect_equal(format_list(list(3, list(from = 2, to = 5))), "3,2-5")
expect_equal(format_list(list(c(3, 8), list(from = 2, to = 5))), "3,8,2-5")
})