Description
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).