-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Document how to handle grouped line list columns #114
Comments
This issue might also link with the {linelist} package and whether there is a line list standard from that package and whether any of the columns are grouped. If so an |
Cheers @joshwlambert. Yes this is exactly how I'd handle it (outside of incidence). Will add an example along the lines of outbreaks::ebola_sim_clean$linelist |>
pivot_wider(names_from = outcome, values_from = date_of_outcome) |>
incidence(
date_index = c(
onset = "date_of_onset",
hospitalisation = "date_of_hospitalisation",
death = "Death"
),
interval = "daily"
) The issue we have is that incidence2 is expecting wide data (albeit potentially aggregated) whereas this is a mixture of wide and long. Whilst it may be possible to adapt allow for long-style "outcome" (and asociated date) columns I think the tidyr approach is so elegant my preference is just to ensure that is documented. As you alude to we could do a lot with an As an aside I may also had a grates version to the examples to illustrate the different approaches. |
Couple of thoughts on this:
|
Interesting. I've always viewed
These are the interesting questions. I think it very much depends on what a typical input linelist (in the non-package sense) looks like. incidence only really handles wide, potentially aggregated, data as this was, in essence, what I inherited spec-wise. If data generally has this form with additional "outcome" and "date of outcome" we could perhaps adapt but I'm loathe to do so with out more of a formal spec of a linelist. An aside: data -> incidence2 -> model fits by groups/counts. but after 2 to 3 years I don't think there is a desire for this and unless a specific need comes up in ${DAYJOB} it's not something I'll push for. |
It is unclear from the current {incidence2} documentation whether the package, specifically
incidence2::incidence()
, can handle grouped columns.An example of such a line list with a grouped column is the Ebola simulated line list in {outbreaks}.
Created on 2024-04-17 with reprex v2.1.0
The way I've been passing line list data like this to
incidence()
is usingtidyr::pivot_wider()
beforehand.Created on 2024-04-17 with reprex v2.1.0
These columns can then be selected using the
date_index
argument inincidence()
.Having the best way to work with this data documented somewhere in the {incidence2} package or add functionality to handle it would be great.
The text was updated successfully, but these errors were encountered: