如何从R数据框中筛选列的唯一组合 [英] How to filter for unique combination of columns from an R dataframe
本文介绍了如何从R数据框中筛选列的唯一组合的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试从R中的数据框中滤除列的子集的重复项.
I am trying to filter out the duplicates of a subset of columns from a dataframe in R.
我对过滤会话,第一个和最后一个的唯一组合感兴趣.以下是我的数据的样子
I am interested in filtering unique combinations of session, first, and last. The following is what my data looks like
session first last city
1 9cf571c8faa67cad2aa9ff41f3a26e38 cat biddix fresno
2 e30f853d4e54604fd62858badb68113a caleb amos
3 2ad41134cc285bcc06892fd68a471cd7 daniel folkers
4 2ad41134cc285bcc06892fd68a471cd7 daniel folkers
5 63a5e839510a647c1ff3b8aed684c2a5 charles pierce flint
6 691df47f2df12f14f000f9a17d1cc40e j franz prescott+valley
7 691df47f2df12f14f000f9a17d1cc40e j franz prescott+valley
8 b3a1476aa37ae4b799495256324a8d3d carrie mascorro brea
9 bd9f1404b313415e7e7b8769376d2705 fred morales las+vegas
10 b50a610292803dc302f24ae507ea853a aurora lee
11 fb74940e6feb0dc61a1b4d09fcbbcb37 andrew price yorkville
推荐答案
请执行以下操作:
unique(df[,c('session','first','last')])
其中df
是您的数据框.
这篇关于如何从R数据框中筛选列的唯一组合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文