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

select causes type conversion #388

Closed
dsweber2 opened this issue Dec 13, 2023 · 2 comments · Fixed by #390
Closed

select causes type conversion #388

dsweber2 opened this issue Dec 13, 2023 · 2 comments · Fixed by #390
Assignees
Labels
bug Something isn't working

Comments

@dsweber2
Copy link
Contributor

Calling select(epi_data, -col_name) on some epi_df converts it into a tibble. There are probably related issues, since this is only one of many dplyr verbs to support.

@dsweber2 dsweber2 added the bug Something isn't working label Dec 13, 2023
@brookslogan
Copy link
Contributor

Can you please provide an example? Sometimes this is intentional: e.g.,

edf %>% select(geo_value)

is not a valid epi df (missing required columns). Sometimes, it's gnarly to fix in general but maybe we could try hacking some fixes for every verb.... e.g.:

edf %>% group_by(geo_value) %>% select(geo_value, time_value, value)

this we probably want to be a grouped epi_df. See probably #223.

@dsweber2
Copy link
Contributor Author

dsweber2 commented Dec 13, 2023

Apologies if is this is a bit verbose; I was trying to add a temporary column, use it in a calculation, and then remove it.

################### setup###########
n_days <- 40
simple_dates <- seq(as.Date("2012-01-01"), by = "day", length.out = n_days)
rand_vals <- rnorm(n_days)
epi_data <- epiprocess::as_epi_df(rbind(tibble(
  geo_value = "al",
  time_value = simple_dates,
  a = 1:n_days,
  b = rand_vals
), tibble(
  geo_value = "ca",
  time_value = simple_dates,
  a = n_days:1,
  b = rand_vals + 10
)))

epi_data %>% mutate(temp_col = a^2) %>% mutate(perm_col = b-a^2) %>% select(-temp_col)

If we're adding checks as part of extending, insisting that select only changes the non-keys would make sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants