使用r编写没有重复的新文件

时间:2018-04-23 09:01:11

标签: r file readfile

我已经将一个txt文件读入R data.frame。有些行是重复的。如何在没有重复的情况下写入新文件(每个副本只有一个副本)  例如:

A; a
B; a
C; a
A; a
C; a
A; b

我必须写到新文件:

A; a
B; a
C; a
A; b

我试过了。我的代码:

#read file 
t = read.table('/home/BigClaster.txt',sep=';',header = FALSE)
........

我在txt文件中有大文件~1269821行。 当我在环境中读取文件RStudio时显示我的行大小没有重复(1,095,079) enter image description here

当我重写到新文件时,我得到重复的行

1 个答案:

答案 0 :(得分:1)

R base

typedef

<强> Dplyr

 t[!duplicated(t), ]

<强>结果

t %>% distinct(.keep_all = TRUE)