Unique {lazy.tools} | R Documentation |
Find unique values of a vector or unique rows of a matrix and their location
Unique(x, sort = 0, decreasing = 0)
x |
a vector or a matrix |
sort |
= 1 to sort the result |
A list of
value
The unique values
loc
The list of length length(value)
containing
the locations of the original elements.
( temp <- Unique( c(1,2,1,5,6,3,5,4,6) ) )
sum( unlist(lapply(temp$loc,length)) )
( temp <- Unique( c(1,2,1,5,6,3,5,4,6), sort=1 ) )
( temp2 <- Unique( rbind(demomat(5,4),demomat(3,4)) ) )
( temp2 <- Unique( rbind(demomat(5,4),demomat(3,4)), sort=1, decreasing=1 ) )