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

bug in group_by #1093

Closed
sfischme opened this issue Mar 25, 2015 · 4 comments
Closed

bug in group_by #1093

sfischme opened this issue Mar 25, 2015 · 4 comments
Assignees
Milestone

Comments

@sfischme
Copy link

Try this:

            time type loc                             call     p cnt
1  1304945116000    a   b 1fb646244dbd6c807005811838b1e5ec 53115   0
2  1304945116000    a   b 6b3dafa1ff257c3891fc87abc78e137e     1   0
3  1304945116000    a   b 6e6f8c68c86173aa7e98b6375e752f89    NA   0
4  1304945116000    a   b d02922f7a545c15632c9ecb39e6da9a2    NA   0
5  1304945116000    a   b 11ce203ca480e56f03a7d1a9591de0e9    NA   0
6  1304945116000    a   b 7dabc9db21bbdc080780f493fe93f2af 53115   0
7  1304945116001    a   b 6b3dafa1ff257c3891fc87abc78e137e     1   1
8  1304945116001    a   b 6e6f8c68c86173aa7e98b6375e752f89    NA   1
9  1304945116001    a   b d02922f7a545c15632c9ecb39e6da9a2    NA   1
10 1304945116001    a   b 11ce203ca480e56f03a7d1a9591de0e9    NA   1

# now compare these two, they should be the same:
q.2 %>% group_by(time, type, loc, call) %>% summarize(n=n()) %>% filter(n>1)
q.2 %>% data.table() %>% group_by(time, type, loc, call) %>% summarize(n=n()) %>% filter(n>1)

@DavidArenburg
Copy link
Member

groub_by is not data.table function...

@sfischme
Copy link
Author

You are right, this produces the expected output:

q.2[,n:=nrow(.SD),by=list(time,type,loc,call)]

@eantonya
Copy link
Contributor

@sfischme simply use .N instead of nrow(.SD)

@arunsrinivasan
Copy link
Member

Convert time column to bit64::integer64 and try again. Or do setNumericRounding(0L) and try again. Read ?setNumericRounding to understand why we do this (including the examples). For large (integer) numbers, we recommend integer64.

I'll add that we recommend bit4::integer64 to ?setNumericRounding and then close the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants