Skip to content

Commit c640cbc

Browse files
committed
fixing #300
1 parent 0026856 commit c640cbc

File tree

1 file changed

+12
-17
lines changed

1 file changed

+12
-17
lines changed

R/covidcast.R

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -69,18 +69,14 @@ parse_source <- function(source, base_url) {
6969
#' @export
7070
as_tibble.covidcast_data_signal_list <- function(x, ...) {
7171
tib <- list()
72-
tib$source <- unname(map_chr(x, "source"))
73-
tib$signal <- unname(map_chr(x, "signal"))
74-
tib$name <- unname(map_chr(x, "name"))
75-
tib$active <- unname(map_lgl(x, "active"))
76-
tib$short_description <- unname(map_chr(x, "short_description"))
77-
tib$description <- unname(map_chr(x, "description"))
78-
tib$time_type <- unname(map_chr(x, "time_type"))
79-
tib$time_label <- unname(map_chr(x, "time_label"))
80-
tib$value_label <- unname(map_chr(x, "value_label"))
81-
tib$format <- unname(map_chr(x, "format"))
82-
tib$category <- unname(map_chr(x, "category"))
83-
tib$high_values_are <- unname(map_chr(x, "high_values_are"))
72+
fields <- c(
73+
"source", "signal", "name", "active", "short_description",
74+
"description", "time_type", "time_label", "value_label",
75+
"format", "category", "high_values_are"
76+
)
77+
for (field in fields) {
78+
tib[[field]] <- unname(map_chr(x, field, .default = ""))
79+
}
8480
as_tibble(tib)
8581
}
8682

@@ -184,11 +180,10 @@ covidcast_epidata <- function(base_url = global_base_url, timeout_seconds = 30)
184180
#' @export
185181
as_tibble.covidcast_data_source_list <- function(x, ...) {
186182
tib <- list()
187-
tib$source <- unname(map_chr(x, "source"))
188-
tib$name <- unname(map_chr(x, "name"))
189-
tib$description <- unname(map_chr(x, "description"))
190-
tib$reference_signal <- unname(map_chr(x, "reference_signal"))
191-
tib$license <- unname(map_chr(x, "license"))
183+
fields <- c("source", "name", "description", "reference_signal", "license")
184+
for (field in fields) {
185+
tib[[field]] <- unname(map_chr(x, field, .default = ""))
186+
}
192187
as_tibble(tib)
193188
}
194189

0 commit comments

Comments
 (0)