官方解释:unique returns a vector, data frame or array like x but with duplicate elements/rows removed.
duplicate:完全一样的
unique主要是返回一个把重复元素或行给删除的向量、数据框或数组
举例:
x <- c(3:5, 11:8, 8 + 0:5)
x
[1] 3 4 5 11 10 9 8 8 9 10 11 12 13
unique(x)
[1] 3 4 5 11 10 9 8 12 13
unique(x, fromLast = TRUE)
[1] 3 4 5 8 9 10 11 12 13 #排序后的
a
[,1] [,2] [,3]
[1,] 1 2 3
[2,] 1 2 4
[3,] 1 3 5
[4,] 1 2 3
unique(a)
[,1] [,2] [,3]
[1,] 1 2 3
[2,] 1 2 4
[3,] 1 3 5 #去除重复的最后一行