Skip to content

Commit dfd768e

Browse files
committed
Use match.arg on covidcast endpoint format argument in R client
Make `Epidata$covidcast` work using the default `format` argument, and make it reject unrecognized `format` arguments. Note that this approach will require keeping the format default arg up to date with all valid options; if an additional format possibility is added but the default arg is not updated, then users attempting to use this formatting option will encounter an error message. --- Before: default format arg produces error ``` > Epidata$covidcast("jhu-csse","confirmed_incidence_num","day","state","20210101","az") Error in vapply(elements, encode, character(1)) : values must be length 1, but FUN(X[[7]]) result is length 2 ``` Before: bogus format arg produces "classic" output ``` > Epidata$covidcast("jhu-csse","confirmed_incidence_num","day","state","20210101","az",format="bogus") [Produces "classic"-formatted response.] ``` --- After: default format arg produces "classic" output ``` > Epidata$covidcast("jhu-csse","confirmed_incidence_num","day","state","20210101","az") [Produces "classic"-formatted response.] ``` After: unrecognized format arg produces error message ``` > Epidata$covidcast("jhu-csse","confirmed_incidence_num","day","state","20210101","az",format="bogus") Error in match.arg(format) : 'arg' should be one of “classic”, “tree” ```
1 parent 41f85d2 commit dfd768e

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

src/client/delphi_epidata.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,7 @@ Epidata <- (function() {
519519
if(!missing(issues) && !missing(lag)) {
520520
stop('`issues` and `lag` are mutually exclusive')
521521
}
522+
format <- match.arg(format)
522523
# Set up request
523524
params <- list(
524525
endpoint = 'covidcast',

0 commit comments

Comments
 (0)