-
Notifications
You must be signed in to change notification settings - Fork 1k
Closed
Labels
HighbugjoinsUse label:"non-equi joins" for rolling, overlapping, and non-equi joinsUse label:"non-equi joins" for rolling, overlapping, and non-equi joins
Milestone
Description
Submitted by: Abiel Reinhart; Assigned to: Arun ; R-Forge link
When using merge()
with option all.x=TRUE
or all=TRUE
, if the column passed to by=
is a character
in the first data.table
, and a factor
in the second, then rows in x
that are not in y
will have their by
column value set to NA
.
Here's an example. Note how country
has become NA
in the first example.
require(data.table)
x <- data.table(country="US")
y <- data.table(country="USA")
y$country <- factor(y$country)
merge(x, y, by="country", all=T)
# country
#1: NA
#2: USA
This will not occur if the merging column is a factor
in the x
input but a character
in the y
input.
x <- data.table(country="US")
y <- data.table(country="USA")
x$country <- factor(x$country)
merge(x, y, by="country", all=T)
# country
#1: US
#2: USA
Metadata
Metadata
Assignees
Labels
HighbugjoinsUse label:"non-equi joins" for rolling, overlapping, and non-equi joinsUse label:"non-equi joins" for rolling, overlapping, and non-equi joins