Skip to content
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

Summarising an epi_df turns it into a tibble #298

Open
mgyliu opened this issue Sep 12, 2022 · 0 comments
Open

Summarising an epi_df turns it into a tibble #298

mgyliu opened this issue Sep 12, 2022 · 0 comments
Assignees

Comments

@mgyliu
Copy link
Contributor

mgyliu commented Sep 12, 2022

If you take an epi_df, group it by some keys, summarise it in some way, and then ungroup it, the result is no longer an epi_df (it's a tibble).

Example

tib <- tibble(
    x = 1:5, y = 1:5,
    time_value = seq(as.Date("2020-01-01"), by = 1, length.out = 5),
    geo_value = "ca") %>% 
  epiprocess::as_epi_df()
is_epi_df(tib) # TRUE

tib2 <- tib %>%
  group_by(time_value, geo_value, x) %>% 
  mutate(ysum = sum(y)) %>% 
  ungroup()
is_epi_df(tib2) # TRUE

tib3 <- tib %>%
  group_by(time_value, geo_value, x) %>% 
  summarise(ysum = sum(y)) %>% 
  ungroup()
is_epi_df(tib3) # FALSE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants