From 2d8f7f7ab07df0cacae74bf6d28574687bf7ba20 Mon Sep 17 00:00:00 2001 From: Dmitry Shemetov Date: Fri, 1 Apr 2022 14:42:04 -0700 Subject: [PATCH 1/2] Fix ifelse bug --- R/endpoints.R | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/R/endpoints.R b/R/endpoints.R index ad30f014..a5879c11 100644 --- a/R/endpoints.R +++ b/R/endpoints.R @@ -1384,6 +1384,8 @@ pvt_twitter <- if (!xor(missing(dates), missing(epiweeks))) { stop("exactly one of `dates` and `epiweeks` is required") } + time_field <- if (!is.null(dates)) create_epidata_field_info("date", "date") + else create_epidata_field_info("epiweek", "epiweek") create_epidata_call( "twitter/", list( @@ -1394,11 +1396,7 @@ pvt_twitter <- ), list( create_epidata_field_info("location", "text"), - ifelse( - !is.null(dates), - create_epidata_field_info("date", "date"), - create_epidata_field_info("epiweek", "epiweek") - ), + time_field, create_epidata_field_info("num", "int"), create_epidata_field_info("total", "int"), create_epidata_field_info("percent", "float") @@ -1431,6 +1429,8 @@ wiki <- if (!xor(missing(dates), missing(epiweeks))) { stop("exactly one of `dates` and `epiweeks` is required") } + time_field <- if (!is.null(dates)) create_epidata_field_info("date", "date") + else create_epidata_field_info("epiweek", "epiweek") create_epidata_call( "wiki/", list( @@ -1442,11 +1442,7 @@ wiki <- ), list( create_epidata_field_info("article", "text"), - ifelse( - !is.null(dates), - create_epidata_field_info("date", "date"), - create_epidata_field_info("epiweek", "epiweek") - ), + time_field, create_epidata_field_info("count", "int"), create_epidata_field_info("total", "int"), create_epidata_field_info("hour", "int"), From f88cfa4582125002086f29c1fd678f543d5403f1 Mon Sep 17 00:00:00 2001 From: Dmitry Shemetov Date: Mon, 4 Apr 2022 10:52:59 -0700 Subject: [PATCH 2/2] Make styler happy --- R/endpoints.R | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/R/endpoints.R b/R/endpoints.R index a5879c11..411caf4c 100644 --- a/R/endpoints.R +++ b/R/endpoints.R @@ -1384,8 +1384,11 @@ pvt_twitter <- if (!xor(missing(dates), missing(epiweeks))) { stop("exactly one of `dates` and `epiweeks` is required") } - time_field <- if (!is.null(dates)) create_epidata_field_info("date", "date") - else create_epidata_field_info("epiweek", "epiweek") + time_field <- if (!is.null(dates)) { + create_epidata_field_info("date", "date") + } else { + create_epidata_field_info("epiweek", "epiweek") + } create_epidata_call( "twitter/", list( @@ -1429,8 +1432,11 @@ wiki <- if (!xor(missing(dates), missing(epiweeks))) { stop("exactly one of `dates` and `epiweeks` is required") } - time_field <- if (!is.null(dates)) create_epidata_field_info("date", "date") - else create_epidata_field_info("epiweek", "epiweek") + time_field <- if (!is.null(dates)) { + create_epidata_field_info("date", "date") + } else { + create_epidata_field_info("epiweek", "epiweek") + } create_epidata_call( "wiki/", list(