我对data.tables有第二个问题。据我所知,合并在数据表中称为连接。如何控制我所拥有的合并类型(一对一,多对一,一对多),以及'using'数据集中的变量是否将替换master数据集中的变量?
另外,如果为了执行合并需要密钥,并且我必须对我的数据进行多次合并,我是否必须不断更改密钥?这对我来说不是很干净......
提前谢谢你, 利玛
答案 0 :(得分:0)
您可以尝试使用merge()
功能。在那里,您可以定义如何合并data.frames。
x, y
data frames, or objects to be coerced to one.
by, by.x, by.y
specifications of the columns used for merging. See ‘Details’.
all
logical; all = L is shorthand for all.x = L and all.y = L, where L is either TRUE or FALSE.
all.x
logical; if TRUE, then extra rows will be added to the output, one for each row in x that has no matching row in y. These rows will have NAs in those columns that are usually filled with values from y. The default is FALSE, so that only rows with data from both x and y are included in the output.
all.y
logical; analogous to all.x.
请尝试?merge
了解详情。
您还可以在这里查看QuickR Merge。