Skip to content
This repository has been archived by the owner on Feb 13, 2023. It is now read-only.

Commit

Permalink
fixing parsing issues when dates/time-series data don't align
Browse files Browse the repository at this point in the history
  • Loading branch information
beansrowning committed Dec 1, 2022
1 parent f4ad6ba commit 4a55ebf
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion R/funcs.R
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,18 @@ baidu_json_parse <- function(json_data) {

area_name <- json_data[["data"]][["name"]]

conformable <- length(time_series_data[[1]]) == length(time_series_data[[2]])

if (!conformable) {
warning(sprintf("%s: symptomatic and asymptomatic lengths differed", area_name, immediate. = TRUE))
return(NULL)
}

out <- tibble(
area_zh = area_name,
date = date_stamps,
# Hack: always assume time series data is right-aligned if date stamps
# aren't conformable
date = tail(date_stamps, n = length(time_series_data[[1]])),
!!!time_series_data
)

Expand Down

0 comments on commit 4a55ebf

Please sign in to comment.