etheleon / dengue

For everything related to NEA dengue
0 stars 0 forks source link

Write SQL transformation for `time_since_switch` feature #9

Closed etheleon closed 3 weeks ago

etheleon commented 1 month ago

Transformation for this was originally written in R in the 00_read_data.R script which references

In the original implementation by Emilie, she just randomly took 1 row (see below) what do you think? @chiachen2019

dominant_serotype_weekly <- dengue_singapore |>
  pivot_longer(cols = c("smooth_denv1", "smooth_denv2", "smooth_denv3", "smooth_denv4"), names_to = "serotype", values_to = "proportion") |>
  group_by(date) |>
  slice(which.max(proportion)) |> # Use slice here to only return one row in cases where there are multiple max
  rename(dominant_serotype_weekly = serotype) |>
  select(date, dominant_serotype_weekly)

You can see my implementation in the associated PR