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

By colon key fix #4376

Merged
merged 6 commits into from
Jun 9, 2020
Merged

By colon key fix #4376

merged 6 commits into from
Jun 9, 2020

Conversation

ColeMiller1
Copy link
Contributor

Closes #4285

DT <- data.table( col1 = c(1, 1, 1),
                  col2 = c("a", "b", "a"),
                  col3 = c("A", "B", "A"),
                  col4 = c(2, 2, 2),
                  key = c("col1", "col4"))

## Current behavior
DT[, .N, by = col1:col4]

##    col1   col2   col3  col4     N
##  <num> <char> <char> <num> <int>
##1:     1      a      A     2     1
##2:     1      b      B     2     1
##3:     1      a      A     2     1

## Fixed behavior (obviously you'll use the above syntax but the output will be this)
DT[, .N, by = c("col1", "col2", "col3", "col4")]

##    col1   col2   col3  col4     N
##   <num> <char> <char> <num> <int>
##1:     1      a      A     2     2
##2:     1      b      B     2     1

@codecov
Copy link

codecov bot commented Apr 12, 2020

Codecov Report

Merging #4376 into master will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #4376   +/-   ##
=======================================
  Coverage   99.60%   99.61%           
=======================================
  Files          73       73           
  Lines       14102    14103    +1     
=======================================
+ Hits        14047    14048    +1     
  Misses         55       55           
Impacted Files Coverage Δ
R/data.table.R 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0e56383...305c5f8. Read the comment docs.

Copy link
Member

@jangorecki jangorecki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mattdowle mattdowle added this to the 1.12.9 milestone Jun 9, 2020
@mattdowle
Copy link
Member

@ColeMiller1 Great PR, thanks. I split out the test like that to test against a fixed result, just in case both sides became both wrong in the future but passed because they matched each other.

@mattdowle mattdowle merged commit 12586af into master Jun 9, 2020
@mattdowle mattdowle deleted the by_colon_key_fix branch June 9, 2020 06:46
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.

"by = colA:colD" produces incorrect result when key = ("colA","colD")
4 participants