我想对数据帧行的比较值比较值,并移除所有匹配的的,这个连续
dat[!dat[1]==dat[2]]
其中
> dat
回报
n1 n2
n1 n4
n4 n5
n1 n3
n4 n4
所以我希望它比较值和删除最后一行,因为两列都有相同的数据。但是当我使用上面的代码,它告诉我
Error in Ops.factor(left, right) : level sets of factors are different
的str(dat)
读取
'data.frame': 5 obs. of 2 variables:
$ V1: Factor w/ 2 levels "n1","n4": 1 1 2 1 2
$ V2: Factor w/ 4 levels "n2","n3","n4",..: 1 3 4 2 3
请在你的问题中发布'str(dat)'的值。我怀疑'dat'是一个data.frame,并且您已经隐式地将您的列转换为因子,而不是字符向量。 – Andrie