我有一组个人反复观察加班的例子:
Name Year Income State Gender
Alice 1 40 NY Female
Alice 2 55 NY Female
Bob 1 30 WA Male
Bob 2 22 WA Male
我想制作一个新的数据框架,描述我所知道的各个特征保持不变。类似的东西:
Name State Gender
Alice NY Female
Bob WA Male
我如何在R?
中这样做答案 0 :(得分:3)
使用您想要的列获取data.frame的unique
将执行此操作:
unique(df[c('Name', 'State', 'Gender')])
# Name State Gender
#1 Alice NY Female
#3 Bob WA Male