@@ -69,18 +69,18 @@ parse_source <- function(source, base_url) {
6969# ' @export
7070as_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+ chr_fields <- c(
73+ " source " , " signal" , " name " , " short_description " ,
74+ " description " , " time_type " , " time_label " , " value_label " ,
75+ " format " , " category " , " high_values_are "
76+ )
77+ for ( field in chr_fields ) {
78+ tib [[ field ]] <- unname(map_chr(x , field , .default = " " ))
79+ }
80+ lgl_fields <- c( " active " )
81+ for ( field in lgl_fields ) {
82+ tib [[ field ]] <- unname(map_lgl (x , field , .default = " " ))
83+ }
8484 as_tibble(tib )
8585}
8686
@@ -184,11 +184,10 @@ covidcast_epidata <- function(base_url = global_base_url, timeout_seconds = 30)
184184# ' @export
185185as_tibble.covidcast_data_source_list <- function (x , ... ) {
186186 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" ))
187+ fields <- c(" source" , " name" , " description" , " reference_signal" , " license" )
188+ for (field in fields ) {
189+ tib [[field ]] <- unname(map_chr(x , field , .default = " " ))
190+ }
192191 as_tibble(tib )
193192}
194193
0 commit comments