You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
The text was updated successfully, but these errors were encountered:
Submitted by: Abiel Reinhart; Assigned to: Arun ; R-Forge link
When using
merge()
with optionall.x=TRUE
orall=TRUE
, if the column passed toby=
is acharacter
in the firstdata.table
, and afactor
in the second, then rows inx
that are not iny
will have theirby
column value set toNA
.Here's an example. Note how
country
has becomeNA
in the first example.This will not occur if the merging column is a
factor
in thex
input but acharacter
in they
input.The text was updated successfully, but these errors were encountered: