【发布时间】:2021-04-20 16:24:23
【问题描述】:
我有 2、1 行 data.tables。
dt1 <- data.table(a = 0, b = 0, c = 0)
dt2 <- data.table(a = 1, c = 5)
我的目标是用dt2 的值更新dt1,以便我得到:
desired_dt <- data.table(a = 1, b = 0, c = 5)
我尝试合并,假设它与共享列名匹配,但没有运气。
dt2[dt1]
Error in `[.data.table`(dt2, dt1) :
When i is a data.table (or character vector), the columns to join by must be specified using 'on='
argument (see ?data.table), by keying x (i.e. sorted, and, marked as sorted, see ?setkey), or by
sharing column names between x and i (i.e., a natural join). Keyed joins might have further speed
benefits on very large data due to x being sorted in RAM.
这不会被视为自然连接吗?对于我所缺少的内容,我将不胜感激!
【问题讨论】:
标签: r merge data.table