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

Drop groups before completing #54

Closed

Conversation

DavisVaughan
Copy link

We are planning on releasing tidyr 1.2.0 towards the end of this month.

We noticed in revdeps that this package was broken. An easy way to reproduce is to install the dev version of tidyr and run this example:

library(SWMPrExtension)
#> Loading required package: SWMPr
#> Loading required package: ggplot2
#> Loading required package: zoo
#> 
#> Attaching package: 'zoo'
#> The following objects are masked from 'package:base':
#> 
#>     as.Date, as.Date.numeric

dat <- elksmwq
dat <- qaqc(dat, qaqc_keep = c('0', '3', '5'))

x <-
  seasonal_boxplot(dat, param = 'do_mgl')
#> Warning in seasonal_boxplot.swmpr(dat, param = "do_mgl"): No historical range
#> specified. Entire time series will be used.
#> Warning in seasonal_boxplot.swmpr(dat, param = "do_mgl"): No target year
#> provided
#> Error: Problem with `summarise()` input `..1`.
#> ℹ `..1 = complete(data = dplyr::cur_data(), ..., fill = fill, explicit = explicit)`.
#> x object 'season' not found
#> ℹ The error occurred in group 1: season = Jan.

The problem comes down to the fact that you were trying to call complete() with a grouped data frame, and you were trying to complete on the group column. This is actually not well defined, as complete() completes "within" each group, so you really shouldn't have access to the group variables. The previous behavior was problematic in many cases (see tidyverse/tidyr#396 and tidyverse/tidyr#966), so we've made a fix to ensure that complete() works correctly with grouped data frames in all cases. This fix comes with the restriction that now you can't specify the group variables in the call to complete().

It looks like everything would work fine if you just drop the groups entirely, so that is what this PR does.

This should work on both the current and development version of tidyr, so you should be able to go ahead and do a patch release. We would greatly appreciate if you could do this so we can release tidyr! Thank you!

@DaveEslinger
Copy link
Member

Thanks for this fix. Our NOAA OCM procedures currently keep me from pulling directly from a non-NOAA contributor. However, I will make the fix as you show in our copy and add you as a contributor. Thanks again!
Dave

DaveEslinger added a commit that referenced this pull request Feb 1, 2022
Changes in summarize require changes in how groups are dropped.  Also fixing for issue #54 raised in SWMPrExtension GitHub comments.
This was referenced Feb 22, 2022
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

Successfully merging this pull request may close these issues.

None yet

2 participants