在R中摆脱重复属性的行 [英] Get rid of rows with duplicate attributes in R

查看:126
本文介绍了在R中摆脱重复属性的行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个大数据框,其中列有:

I have a big dataframe with columns such as:

ID, time, OS, IP

该数据帧的每一行对应一个条目。在某些 ID 的数据帧内存在几个条目(行)。我想摆脱这些多行(显然,其他属性对于相同的ID会有所不同)。或者放不同:我只想为每个ID单独一个条目(行)。

Each row of that dataframe corresponds to one entry. Within that dataframe for some IDs several entries (rows) exist. I would like to get rid of those multiple rows (obviously the other attributes will differ for the same ID). Or put different: I only want one single entry (row) for each ID.

当我使用唯一 ID列,我只接收级别(或每个唯一ID),但是我想保留其他属性。
我试图使用 apply(x,2,unique(data $ ID)),但这也不行。

When I use unique on the ID column, I only receive the levels (or each unique ID), but I want to keep the other attributes as well. I have tried to use apply(x,2,unique(data$ID)), but this does not work either.

推荐答案

subset(data,!duplicated(data$ID))

应该做的伎俩

这篇关于在R中摆脱重复属性的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆