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

Merge with NA in factor key copies NA row #945

Closed
stewbasic opened this issue Nov 11, 2014 · 1 comment
Closed

Merge with NA in factor key copies NA row #945

stewbasic opened this issue Nov 11, 2014 · 1 comment
Assignees
Milestone

Comments

@stewbasic
Copy link

I'm using data.table v1.9.4 on R 3.0.2.

I'm merging two data.tables with a key of type factor containing an NA entry. For keys appearing only in the first table, the columns from the second table don't contain NA, as expected from ?merge, but instead get copied from the NA row. See row 3, column v.y in the following example:

x<-data.table(k=as.factor(c(NA,1,2)),v=c(0,1,2))
y<-data.table(k=as.factor(c(NA,1,3)),v=c(0,1,3))
merge(x,y,all=T,by="k")
#     k v.x v.y
#1: NA   0   0
#2:  1   1   1
#3:  2   2   0
#4:  3  NA   3

This is very similar to the issue reported in this SO post, but it should be fixed as of v1.8.11 according to the comment there.

@arunsrinivasan
Copy link
Member

@stewbasic thanks for the nice minimal example.

@arunsrinivasan arunsrinivasan added this to the v1.9.8 milestone Dec 4, 2014
@arunsrinivasan arunsrinivasan modified the milestones: v1.9.6, v1.9.8 Feb 8, 2015
@arunsrinivasan arunsrinivasan self-assigned this Feb 8, 2015
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

2 participants