Skip to content

Commit

Permalink
patch: get select working with grouping
Browse files Browse the repository at this point in the history
  • Loading branch information
dsweber2 committed Jan 9, 2024
1 parent e40d02a commit 39225f0
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
1 change: 1 addition & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ Collate:
'data.R'
'epi_df.R'
'epiprocess.R'
'group_by_epi_df_methods.R'
'methods-epi_archive.R'
'grouped_epi_archive.R'
'growth_rate.R'
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ S3method(groups,grouped_epi_archive)
S3method(next_after,Date)
S3method(next_after,integer)
S3method(print,epi_df)
S3method(select,epi_df)
S3method(summary,epi_df)
S3method(ungroup,epi_df)
S3method(ungroup,grouped_epi_archive)
Expand Down
22 changes: 19 additions & 3 deletions tests/testthat/test-epi_df.R
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,22 @@ test_that("as_epi_df errors when additional_metadata is not a list", {
pol = rep(c("blue", "swing", "swing"), each = 2))

expect_error(
as_epi_df(ex_input, additional_metadata = c(other_keys = "state", "pol")),
"`additional_metadata` must be a list type.")
})
as_epi_df(ex_input, additional_metadata = c(other_keys = "state", "pol")),
"`additional_metadata` must be a list type."
)
})


test_that("grouped epi_df maintains type for select", {
tib <- tibble::tibble(
x = 1:10, y = 1:10,
time_value = rep(seq(as.Date("2020-01-01"), by = 1, length.out = 5), times = 2),
geo_value = rep(c("ca", "hi"), each = 5)
)

epi_tib <- epiprocess::new_epi_df(tib)
epi_tib
grouped_epi <- epi_tib %>% group_by(geo_value)
selected_df <- grouped_epi %>% select(-y)
expect_true("epi_df" %in% class(selected_df))
})

0 comments on commit 39225f0

Please sign in to comment.