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

Popular posts from this blog

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

html - Outlook 2010 Anchor (url/address/link) -

android - How to create dynamically Fragment pager adapter -