Skip to content

Commit

Permalink
Fix prev_detection table to rename WILD to WPV1
Browse files Browse the repository at this point in the history
Co-Authored-By: lizkrowlucal <[email protected]>
  • Loading branch information
truenomad and lizkrowlucal committed Sep 16, 2024
1 parent cf39d01 commit 40b2978
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
3 changes: 2 additions & 1 deletion R/globals.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ globalVariables(
"virus_type", "CollectionDate", "Admin0Name", "Admin1Name",
"Admin2Name", "Detections", "Emergence/Cluster Group", "NtChanges",
"Previous Detection", "SurveillanceTypeName", "VdpvEmergenceGroupName",
"VirusDate", "VirusTypeName", "WildClusterName"
"VirusDate", "VirusTypeName", "WildClusterName",
"Days Since Last Detections"
)
)
19 changes: 14 additions & 5 deletions R/prep_detections.R
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,10 @@ prep_new_detections_report <- function(polis_df_old,


prev_detection <- polis_df_old |>
dplyr::filter(stringr::str_detect(VirusTypeName, "^WILD|^VDPV|^cVDPV")) |>
dplyr::mutate(
VirusTypeName = ifelse(VirusTypeName == "WILD1", "WPV1", VirusTypeName)
) |>
dplyr::filter(stringr::str_detect(VirusTypeName, "^WPV|^VDPV|^cVDPV")) |>
dplyr::filter(SurveillanceTypeName %in% c("AFP", "Environmental")) |>
dplyr::mutate(VirusDate = as.Date(VirusDate)) |>
dplyr::group_by(Admin0Name, VirusTypeName) |>
Expand Down Expand Up @@ -136,8 +139,13 @@ prep_new_detections_report <- function(polis_df_old,
dplyr::left_join(
prev_detection,
by = c("Admin0Name", "VirusTypeName")
) |>
dplyr::mutate(
`Days Since Last Detections` =
VirusDate - `Previous Detection`
)


reslist <- result |>
dplyr::filter(
# VirusTypeName == "VDPV2"
Expand Down Expand Up @@ -168,9 +176,10 @@ prep_new_detections_report <- function(polis_df_old,
),
prev_det = ifelse(
is.na(`Previous Detection`),
"",
# paste(
# " This virus was reported for the first time in that country"),
# "" # ,
paste(
" This virus was reported for the first time in that country"
),
paste0(
" With last known detection in that country being in ",
`Previous Detection`, "."
Expand Down Expand Up @@ -259,7 +268,7 @@ prep_new_detections_report <- function(polis_df_old,
}

list(
overview = overview,
detections_table = overview,
country_specific = country_specific,
result = result
)
Expand Down

0 comments on commit 40b2978

Please sign in to comment.