# R program to illustrate# unique function# Initializing some set of numbers
x <- c(1:10,5:9)
x
# Calling unique() function to print# unique set of numbers
unique(x)
R
输出
[1]1234567891056789[1]12345678910
R
例2 :
# R program to illustrate# unique function# Initializing a matrix
x <- matrix(rep(1:9, length.out =18),
nrow =6, ncol =3, byrow = T)
x
# Calling unique() function to print# unique set of numbers in the matrix
unique(x)