Skip to content

Prevent incorrect data.table-connected metadata out of epix_as_of #561

@brookslogan

Description

@brookslogan
library(epiprocess)
#> Registered S3 method overwritten by 'tsibble':
#>   method               from 
#>   as_tibble.grouped_df dplyr
#> 
#> Attaching package: 'epiprocess'
#> The following object is masked from 'package:stats':
#> 
#>     filter
archive_cases_dv_subset %>%
  epix_as_of(as.Date("2021-11-29")) %>%
  attributes() %>%
  {.[names(.) != "row.names"]} # row.names isn't relevant, clogs output
#> $names
#> [1] "geo_value"       "time_value"      "percent_cli"     "case_rate_7d_av"
#> 
#> $class
#> [1] "epi_df"     "tbl_df"     "tbl"        "data.frame"
#> 
#> $.internal.selfref
#> <pointer: 0x55a9589a7060>
#> 
#> $sorted
#> [1] "geo_value"  "time_value" "version"   
#> 
#> $metadata
#> $metadata$geo_type
#> [1] "state"
#> 
#> $metadata$time_type
#> [1] "day"
#> 
#> $metadata$as_of
#> [1] "2021-11-29"
#> 
#> $metadata$other_keys
#> character(0)

Created on 2024-11-03 with reprex v2.1.1

.internal.selfref and sorted are used by the data.table package on data.table objects and maybe at some point some in-place conversions and mostly-internal shallow conversions. We probably should remove them. sorted's value is incorrect anyway given that there's no version column in the output. Right now I only notice it being annoying when writing some tests.

  • prevent attribute attachment; maybe as.data.frame or setDT before as_tibble
  • side question (deferrable): some attribute-related handling in data.table isn't how I remembered it; check whether the sorted attribute set in epix_detailed_restricted_mutate before setDT is actually being used anymore (/ ever?). If so, means above is more important to address

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions