-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Default behavior of count() seems to have changed in 1.0.0 #5298
Comments
I don't remember |
I like the |
Seconded - I and others I work with regularly use the That aside, it seems like a really counter-intuitive default to implicitly assume that weighting is intended because there's a variable called The reference to counting rows in the message looks incorrect at the moment also - setting library(dplyr, warn.conflicts = FALSE)
df <- tibble(x = c(1, 1, 1, 2, 2, 2), n = 1:6)
df %>% count(x, wt = n)
#> # A tibble: 2 x 2
#> x n
#> <dbl> <int>
#> 1 1 6
#> 2 2 15
df %>% count(x, wt = 1)
#> # A tibble: 2 x 2
#> x n
#> <dbl> <dbl>
#> 1 1 1
#> 2 2 1
df %>% count(x, wt = n())
#> # A tibble: 2 x 2
#> x n
#> <dbl> <int>
#> 1 1 3
#> 2 2 3 Created on 2020-06-09 by the reprex package (v0.3.0) |
Hello all, I have a similar issue not in count but in tally. I used to use tally to add up how many rows of data I had for each siteID. Thanks @gorcha that wt = n () fixes the issue:- data2<- data%>% Now I just need to remember which dataframes have n in them. |
The root problem appears to be that an inconsistency crept in between count and tally (https://github.com/tidyverse/dplyr/blob/v0.8.5/R/count-tally.R#L25-L33) — in my mind However, it looks like Since this was a fairly major and unplanned change, I think the best option is to roll it back in 1.0.1 so that |
Alternatively, maybe it's time to make |
Noticed that the default behavior of count() has changed in 1.0.0 but wasn't listed as a breaking change in the release notes
0.8.5
1.0.0
Originally posted by @nhols in #5265 (comment)
The text was updated successfully, but these errors were encountered: