Skip to content

When decaying from epi_df to tibble, remove metadata that doesn't make sense #193

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

Closed
brookslogan opened this issue Aug 8, 2022 · 1 comment · Fixed by #196
Closed

When decaying from epi_df to tibble, remove metadata that doesn't make sense #193

brookslogan opened this issue Aug 8, 2022 · 1 comment · Fixed by #196
Assignees
Labels
bug Something isn't working P3 very low priority

Comments

@brookslogan
Copy link
Contributor

brookslogan commented Aug 8, 2022

From discussion from #185. Operations such as [ can remove essential columns from an epi_df, so we decay from an epi_df to a tibble; however, the metadata sticks around, and some of it doesn't make sense.

library(dplyr)
#> 
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, setequal, union
library(epiprocess)
#> 
#> Attaching package: 'epiprocess'
#> The following object is masked from 'package:stats':
#> 
#>     filter
decayed =
  new_epi_df(tibble(geo_value="ak",time_value=1L,value=1L)) #%>%
  #select(-geo_value)
decayed[-1]
#> # A tibble: 1 × 2
#>   time_value value
#>        <int> <int>
#> 1          1     1
decayed[-1] %>% attr("metadata")
#> $geo_type
#> [1] "state"
#> 
#> $time_type
#> [1] "custom"
#> 
#> $as_of
#> [1] "2022-08-08 09:15:22 PDT"

Created on 2022-08-08 by the reprex package (v2.0.1)

Here, geo_type doesn't make sense. We didn't have any other_keys to begin with, but if we did, they might not make sense either. In other cases, different metadata will be invalidated. We might want to just drop all the metadata in all cases to keep it simple.

Marking as P3 as the presence of metadata that doesn't make sense on a tibble shouldn't affect its operation, and if we convert back to an epi_df using {new,as}_epi_df, it looks like the only metadata that will be carried over is as_of, which might or might not make sense depending on what intermediate operations have occurred. We should probably make it easier to override this as_of setting, though (intersects with #166).

@brookslogan brookslogan added bug Something isn't working P3 very low priority labels Aug 8, 2022
@rachlobay
Copy link
Collaborator

Modified the above ex. to explicitly use indexing to make sure goes through [.epi_df. As discussed, will go for the simplest soln to drop all metadata.

@rachlobay rachlobay self-assigned this Aug 8, 2022
@rachlobay rachlobay linked a pull request Aug 9, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working P3 very low priority
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants