epiforecasts / RtD3

Rt visualisation in D3
https://epiforecasts.io/RtD3/
Other
6 stars 2 forks source link

join_RtD3_data #21

Closed hamishgibbs closed 3 years ago

hamishgibbs commented 3 years ago

Incorporating join_RtD3_data in RtD3, not covid.

https://github.com/epiforecasts/covid/blob/master/utils/join_RtD3_data.R

I can see that this function is about ensuring required column names (region -> Region) and joining the national estimates to subnational estimates?

Is that for display in the subnational pages?

14 should address the region -> Region change.

Then with this added to RtD3, will it be general for people who do not have a web framework - or have their own url patterns?

@seabbs

seabbs commented 3 years ago

So the idea here is to take two sets of Rt estimates (say global estimates and UN region estimates) then glue them together in the format that RtD3 understands (whilst also filtering for a chosen country). That lets you have say the national estimate as the default for a set of subnational estimates... (https://epiforecasts.io/covid/posts/national/united-kingdom/).

Perhaps a better way to do this would be.

national_esitmates <- RtD3::read....

subnational_estimates <- RtD3::read...

estimates <- RtD3::join_data(national_esimates, subnational_estimates)

RtD3::summaryWidget......

So literally just do the somewhat complicated and dull join for people (though this throws away the handy filter on country functionality I would need (but can put in elsewhere)). This code basically,

join_RtD3_data <- function(rtData, rtData2) {

  # Join the subregional and national estimates together.
  rtData <- purrr::map2(rtData, rtData2, 
                        ~ data.table::rbindlist(list(
                          .x[, lapply(.SD, as.character)], 
                          .y[, lapply(.SD, as.character)]),
                        use.names = TRUE, fill = TRUE))
  return(rtData)
}

Potentially the region filter could be added to RtD3::readInEpiNow2? Can imagine it being handy potentially.

Potentially the answer is that this function is not really needed in RtD3. Your call @hamishgibbs

hamishgibbs commented 3 years ago

What is the purpose of the country filter?

hamishgibbs commented 3 years ago

Sounds good to me to have RtD3::join_data added as it is nice to have the widgets initiate with national estimates

seabbs commented 3 years ago

Confuse the mind and dazzle the senses....

To let you join the UK national estimate into the UK subnational estimates (used here: https://github.com/epiforecasts/covid/blob/master/utils/subnational_defaults.R) which I can see being a thing others may want to do (or just show a subset of some estimates loaded in from EpiNow2).

seabbs commented 3 years ago

though to fit the naming scheme probably needs to be called joinrtData or some such?

hamishgibbs commented 3 years ago

joinRtData? although rtData <- joinRtData gives me camelcase anxiety

hamishgibbs commented 3 years ago

I support putting this in. Sounds good - would you like to do it?

seabbs commented 3 years ago

yes, will do over the weekend. Hence why snake case is the best case.

hamishgibbs commented 3 years ago

Thanks!

hamishgibbs commented 3 years ago

🐫

seabbs commented 3 years ago

done in #32