r - Get row numbers of unique rows in a matrix -
i have matrix has unique rows , row names of unique rows only.
m <- matrix( data = c(1,1,2,1,1,2,1,1,2), ncol = 3 )
if expected row index '3' other 2 rows duplicates, use duplicated
logical index , wrap which
numeric index.
which(!(duplicated(m)|duplicated(m,fromlast=true))) #[1] 3
if consider 1st , 3rd unique
rows,
which(!duplicated(m))
Comments
Post a Comment