Reputation: 10166
As a minimal demonstration, say I want to copy factor column y
from dt2
to dt1
:
library(data.table)
dt1 <- data.table(id = 1:2, x = 3:4, key = "id")
dt2 <- data.table(id = 2:3, y = factor(letters[1:2]), key = "id")
dt1[dt2, y := y] # do copy
class(dt1$y) # y ended up as integers in dt1
## "integer"
class(dt2$y) # what y should be
## "factor"
y
is not getting assigned as a factor. Any solutions?
Upvotes: 0
Views: 188
Reputation: 10166
To paraphrase Arun:
CsubsetVector
errors when
installing from github, see issue #757Upvotes: 1