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]merge is now merging on col order instead of name #1290

Closed
ChristK opened this issue Aug 25, 2015 · 2 comments
Closed

[Bug]merge is now merging on col order instead of name #1290

ChristK opened this issue Aug 25, 2015 · 2 comments
Assignees
Labels
Milestone

Comments

@ChristK
Copy link

ChristK commented Aug 25, 2015

Please see example below

require(data.table) #latest github version

DT1 <- data.table(sex = rep(1:2, 5),
                  group = rep(letters[1:5], 2),
                  V1 = 1:10)

DT2 <- data.table(group = rep(letters[1:5], 2), # note the different order
                  sex = rep(1:2, 5),
                  V2 = 1:10)

merge(
  DT1, DT2, by = c("sex", "group")
)

# WRONG! sex should be numbers and group letters
#   sex group V1 V2
#1:   a     1  1  1
#2:   a     2  6  6
#3:   b     1  7  7
#4:   b     2  2  2
#5:   c     1  3  3
#6:   c     2  8  8
#7:   d     1  9  9
#8:   d     2  4  4
#9:   e     1  5  5
#10:   e     2 10 10

 sessionInfo()

#R version 3.2.2 (2015-08-14)
#Platform: x86_64-pc-linux-gnu (64-bit)
#Running under: Ubuntu 14.04.2 LTS
#
#locale:
# [1] LC_CTYPE=en_GB.UTF-8       LC_NUMERIC=C              
# [3] LC_TIME=en_GB.UTF-8        LC_COLLATE=en_GB.UTF-8    
# [5] LC_MONETARY=en_GB.UTF-8    LC_MESSAGES=en_GB.UTF-8   
# [7] LC_PAPER=en_GB.UTF-8       LC_NAME=C                 
# [9] LC_ADDRESS=C               LC_TELEPHONE=C            
#[11] LC_MEASUREMENT=en_GB.UTF-8 LC_IDENTIFICATION=C       

#attached base packages:
#[1] stats     graphics  grDevices utils     datasets 
#[6] methods   base     
#
#other attached packages:
#[1] data.table_1.9.5
#
#loaded via a namespace (and not attached):
#[1] tools_3.2.2  chron_2.3-47

The bug was introduced probably the last week. (Edited with simpler example)

@arunsrinivasan
Copy link
Member

Thanks for the nice report. Fixed.

@ChristK
Copy link
Author

ChristK commented Aug 25, 2015

Thank you!

It took me more time to report it than you to fix it 👍

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

No branches or pull requests

2 participants