Skip to content

Commit

Permalink
Add extra dataset with NS Respiratory Watch data
Browse files Browse the repository at this point in the history
- ccodwg/CovidTimelineCanada#124
- Also reorganize extra dataset function
  • Loading branch information
jeanpaulrsoucy committed Nov 2, 2023
1 parent d880062 commit f5f7149
Showing 1 changed file with 45 additions and 11 deletions.
56 changes: 45 additions & 11 deletions R/extra_datasets.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,29 @@ extra_datasets <- function() {
write.csv(ter, file.path("extra_data", "territories_rvdss_since_2022-09-03", "territories_rvdss_since_2022-09-03.csv"), row.names = FALSE, quote = 1:3, na = "")
},
error = function(e) {
cat("Error in updating territories data:", fill = TRUE)
print(e)
cat("Error in downloading territories data", fill = TRUE)
}
)

# sk biweekly HR-level case snapshots
tryCatch(
{
## process
sk <- read_d("raw_data/reports/sk/sk_crisp_report.csv") |>
dplyr::transmute(.data$date_start, .data$date_end, .data$region, .data$sub_region_1, cases_weekly = .data$cases) |>
dplyr::filter(.data$date_start >= as.Date("2022-12-25") & !is.na(.data$sub_region_1) & !is.na(.data$cases_weekly)) |>
convert_hr_names()

## process
sk <- read_d("raw_data/reports/sk/sk_crisp_report.csv") |>
dplyr::transmute(.data$date_start, .data$date_end, .data$region, .data$sub_region_1, cases_weekly = .data$cases) |>
dplyr::filter(.data$date_start >= as.Date("2022-12-25") & !is.na(.data$sub_region_1) & !is.na(.data$cases_weekly)) |>
convert_hr_names()

## write file
utils::write.csv(sk, file.path("extra_data", "sk_biweekly_cases_hr", "sk_biweekly_cases_hr.csv"), row.names = FALSE, quote = 1:4)
rm(sk) # clean up
## write file
utils::write.csv(sk, file.path("extra_data", "sk_biweekly_cases_hr", "sk_biweekly_cases_hr.csv"), row.names = FALSE, quote = 1:4)
rm(sk) # clean up
},
error = function(e) {
cat("Error in updating SK biweekly HR-level case snapshots:", fill = TRUE)
print(e)
}
)

# PHAC individual-level data

Expand Down Expand Up @@ -223,8 +230,8 @@ extra_datasets <- function() {
}
},
error = function(e) {
print(e)
cat("Error in updating individual-level PHAC dataset:", fill = TRUE)
print(e)
}
)

Expand All @@ -246,4 +253,31 @@ extra_datasets <- function() {
cat("Error in updating hospital/ICU extra data report:", fill = TRUE)
}
)

## NS Respiratory Watch extra data
tryCatch(
{
d <- read_d("raw_data/reports/ns/ns_respiratory_watch_report.csv")
d <- d |>
dplyr::transmute(
.data$date_start,
.data$date_end,
.data$region,
.data$sub_region_1,
.data$cases,
.data$deaths,
.data$hosp_admissions,
.data$icu_admissions
)
utils::write.csv(
d,
file.path("extra_data", "ns_extra_respiratory_watch", "ns_extra_respiratory_watch.csv"),
row.names = FALSE,
na = "")
},
error = function(e) {
cat("Error in updating NS Respiratory Watch extra data:", fill = TRUE)
print(e)
}
)
}

0 comments on commit f5f7149

Please sign in to comment.