Skip to content

Commit 7f9e60c

Browse files
committed
Fix spacings
1 parent 100b467 commit 7f9e60c

File tree

8 files changed

+39
-69
lines changed

8 files changed

+39
-69
lines changed

R/check.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,4 +88,4 @@ check_single_int_param <- function(name, value, required = TRUE) {
8888
name = name, value = value, class = "invalid_argument"
8989
)
9090
}
91-
}
91+
}

R/constants.R

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
2-
31
version <- "1.0.0"
42
http_headers <- httr::add_headers("User-Agent" = paste0("delphi_epidata", version))
5-
global_base_url <- "https://delphi.cmu.edu/epidata/"
3+
global_base_url <- "https://delphi.cmu.edu/epidata/"

R/covidcast.R

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
21
parse_signal <- function(signal, base_url) {
32
class(signal) <- c("covidcast_data_signal", class(signal))
43
signal$key <- paste(signal$source, signal$signal, sep = ":")
54

6-
#'
75
#' fetch covidcast data
86
#'
97
#' @param data_source data source to fetch
@@ -48,7 +46,6 @@ parse_source <- function(source, base_url) {
4846
r
4947
}
5048

51-
5249
as.data.frame.covidcast_data_signal_list <- function(signals, ...) {
5350
as.data.frame(do.call(rbind, lapply(signals, function(x) {
5451
sub <- x[c(
@@ -77,7 +74,6 @@ as.data.frame.covidcast_data_signal_list <- function(signals, ...) {
7774
}), ...)
7875
}
7976

80-
8177
print.covidcast_data_source <- function(source, ...) {
8278
print(source$name, ...)
8379
print(source$source, ...)
@@ -86,7 +82,6 @@ print.covidcast_data_source <- function(source, ...) {
8682
print(signals[, c("signal", "name", "short_description")], ...)
8783
}
8884

89-
#'
9085
#' creates the covidcast epidata helper
9186
#'
9287
#' @param base_url optional alternative base url
@@ -122,7 +117,6 @@ covidcast_epidata <- function(base_url = global_base_url) {
122117
)
123118
}
124119

125-
126120
as.data.frame.covidcast_data_source_list <- function(sources, ...) {
127121
as.data.frame(do.call(rbind, lapply(sources, function(x) {
128122
sub <- x[c(
@@ -151,4 +145,4 @@ print.covidcast_epidata <- function(epidata, ...) {
151145
if (nrow(signals) > 5) {
152146
print(paste0((nrow(signals) - 5), " more..."))
153147
}
154-
}
148+
}

R/epidatacall.R

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
2-
3-
41
create_epidata_call <- function(endpoint, params, meta = NULL,
52
only_supports_classic = FALSE) {
63
stopifnot(is.character(endpoint), length(endpoint) == 1)
@@ -22,7 +19,6 @@ create_epidata_call <- function(endpoint, params, meta = NULL,
2219
)
2320
}
2421

25-
#'
2622
#' use a different base url
2723
#'
2824
#' @param epidata_call and instance of epidata_call
@@ -66,7 +62,6 @@ full_url <- function(epidata_call) {
6662
join_url(epidata_call$base_url, epidata_call$endpoint)
6763
}
6864

69-
#'
7065
#' returns the full request url for the given epidata_call
7166
#'
7267
#' @param epidata_call and instance of epidata_call
@@ -99,7 +94,6 @@ request_impl <- function(epidata_call, format_type, fields = NULL) {
9994
do_request(url, params)
10095
}
10196

102-
#'
10397
#' fetches the data and returns the classic format
10498
#'
10599
#' @param epidata_call and instance of epidata_call
@@ -128,7 +122,6 @@ fetch_classic <- function(epidata_call, fields = NULL, disable_date_parsing = FA
128122
m
129123
}
130124

131-
#'
132125
#' fetches the data and returns the josn format
133126
#'
134127
#' @param epidata_call and instance of epidata_call
@@ -156,7 +149,6 @@ fetch_json <- function(epidata_call, fields = NULL, disable_date_parsing = FALSE
156149
parse_data_frame(epidata_call, jsonlite::fromJSON(r), disable_date_parsing = disable_date_parsing)
157150
}
158151

159-
#'
160152
#' fetches the data and returns the CSV text
161153
#'
162154
#' @param epidata_call and instance of epidata_call
@@ -215,7 +207,6 @@ info_to_type <- function(info, disable_date_parsing = FALSE) {
215207
r
216208
}
217209

218-
#'
219210
#' fetches the data and returns data frame
220211
#'
221212
#' @param epidata_call and instance of epidata_call
@@ -269,8 +260,6 @@ fetch_tbl <- function(epidata_call, fields = NULL, disable_date_parsing = FALSE)
269260
tbl
270261
}
271262

272-
273-
#'
274263
#' fetches the data and returns data frame
275264
#'
276265
#' @param epidata_call and instance of epidata_call
@@ -281,4 +270,4 @@ fetch_tbl <- function(epidata_call, fields = NULL, disable_date_parsing = FALSE)
281270
#' @export
282271
fetch_df <- function(epidata_call, fields = NULL, disable_date_parsing = FALSE) {
283272
as.data.frame(fetch_tbl(epidata_call, fields, disable_date_parsing))
284-
}
273+
}

R/model.R

Lines changed: 30 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
2-
3-
#'
41
#' builds a new EpiRange instances
52
#'
63
#' @param from start
@@ -21,36 +18,35 @@ epirange <- function(from, to) {
2118
structure(list(from = from, to = to), class = "EpiRange")
2219
}
2320

24-
create_epidata_field_info <-
25-
function(name,
26-
type,
27-
description = "",
28-
categories = c()) {
29-
stopifnot(is.character(name) && length(name) == 1)
30-
stopifnot(
31-
is.character(type) &&
32-
length(type) == 1 &&
33-
type %in% c(
34-
"text",
35-
"int",
36-
"float",
37-
"date",
38-
"epiweek",
39-
"categorical",
40-
"bool"
41-
)
42-
)
43-
stopifnot(is.character(description) && length(description) == 1)
44-
structure(
45-
list(
46-
name = name,
47-
type = type,
48-
description = description,
49-
categories = categories
50-
),
51-
class = "EpidataFieldInfo"
52-
)
53-
}
21+
create_epidata_field_info <- function(name,
22+
type,
23+
description = "",
24+
categories = c()) {
25+
stopifnot(is.character(name) && length(name) == 1)
26+
stopifnot(
27+
is.character(type) &&
28+
length(type) == 1 &&
29+
type %in% c(
30+
"text",
31+
"int",
32+
"float",
33+
"date",
34+
"epiweek",
35+
"categorical",
36+
"bool"
37+
)
38+
)
39+
stopifnot(is.character(description) && length(description) == 1)
40+
structure(
41+
list(
42+
name = name,
43+
type = type,
44+
description = description,
45+
categories = categories
46+
),
47+
class = "EpidataFieldInfo"
48+
)
49+
}
5450

5551
parse_value <- function(info, value, disable_date_parsing = FALSE) {
5652
stopifnot(inherits(info, "EpidataFieldInfo"))
@@ -84,4 +80,4 @@ parse_data_frame <- function(epidata_call, df, disable_date_parsing = FALSE) {
8480
}
8581
}
8682
df
87-
}
83+
}

R/parse.R

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
1-
21
parse_api_date <- function(value) {
32
as.Date(as.character(value), format = "%Y%m%d")
43
}
54

6-
7-
8-
#'
95
#' parses a week
106
#' @importFrom MMWRweek MMWRweek2Date
117
#' @return a date
@@ -34,4 +30,4 @@ fields_to_predicate <- function(fields = NULL) {
3430
function(x) {
3531
!(x %in% to_exclude) && (length(to_include) == 0 || x %in% to_include)
3632
}
37-
}
33+
}

R/request.R

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,19 @@ join_url <- function(url, endpoint) {
55
paste0(url, endpoint)
66
}
77

8-
#'
98
#' performs the request
109
#' @importFrom httr RETRY
1110
do_request <- function(url, params) {
1211
# don't retry in case of certain status codes
13-
res <- httr::RETRY("GET", url,
12+
res <- RETRY("GET", url,
1413
query = params, http_headers,
1514
terminate_on = c(400, 401, 403, 405, 414, 500)
1615
)
1716
if (res$status_code == 414) {
18-
res <- httr::RETRY("POST", url,
17+
res <- RETRY("POST", url,
1918
body = params, encode = "form", http_headers,
2019
terminate_on = c(400, 401, 403, 405, 414, 500)
2120
)
2221
}
2322
res
24-
}
23+
}

R/utils.R

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
2-
31
# Helper function to cast values and/or ranges to strings
42
format_item <- function(value) {
53
if (inherits(value, "EpiRange")) {
@@ -19,4 +17,4 @@ format_list <- function(values) {
1917
values <- list(values)
2018
}
2119
paste(sapply(values, format_item), collapse = ",")
22-
}
20+
}

0 commit comments

Comments
 (0)