【发布时间】:2021-01-01 00:05:46
【问题描述】:
假设我有以下data.table:
dt <- data.table(a = 1:2, b = 1:2, c = c(1, 1))
# dt
# a b c
# 1: 1 1 1
# 2: 2 2 1
创建第四列d 指示每行中预先存在的值都相同的最快方法是什么,因此生成的 data.table 将如下所示?
# dt
# a b c d
# 1: 1 1 1 identical
# 2: 2 2 1 not_identical
我想避免使用duplicated 函数,并希望坚持使用identical 或类似函数,即使这意味着遍历每一行中的项目。
【问题讨论】:
-
重复有什么问题?
-
@MichaelChirico 我认为
duplicated无法检测到班级差异,而identical可以?
标签: r data.table rowwise