i have a data.table :
data.table(id = c(rep(1,5)),
year = c(rep(2015,3), rep(2016,2)),
class = c(rep("A", 3), rep("B", 2)),
origin = c("Europe", "Asia", "Africa", "Europe", "Asia"),
count = c(30299, 3, 34, 2, 800))
id year class origin count
1: 1 2015 A Europe 30299
2: 1 2015 A Asia 3
3: 1 2015 A Africa 34
4: 1 2016 B Europe 2
5: 1 2016 B Asia 800
but some of the information is not correct. I want to overwrite the region using another data.table:
data.table(id = c(1),
year = c(2015,2016),
class = c("A", "B"),
origin = c("Europe", "Asia"))
id year class origin
1: 1 2015 A Europe
2: 1 2016 B Asia
so that the original table becomes :
id year class origin count
1: 1 2015 A Europe 30299
2: 1 2015 A Europe 3
3: 1 2015 A Europe 34
4: 1 2016 B Asia 2
5: 1 2016 B Asia 800
i ried doing this with merge
and also within
, but i am getting errors.