[R] unique rows

arun smartpink111 at yahoo.com
Tue Jan 28 23:20:23 CET 2014


Hi,
use ?unique
 unique(dat)
A.K.


Hi, I wanted to remove redundant rows (with same entry in columns) in a data frame. For example, with this data frame: 

> dat<-cbind(x=c('a','a','b','b','c','c'),y=c('x','x','d','s','g','g')) 
> dat 
     x   y  
[1,] "a" "x" 
[2,] "a" "x" 
[3,] "b" "d" 
[4,] "b" "s" 
[5,] "c" "g" 
[6,] "c" "g" 

after removing the redundancy, the end results should be 

     x   y  
[1,] "a" "x" 
[2,] "b" "d" 
[3,] "b" "s" 
[4,] "c" "g" 

what is the best way to do this? 

Thanks 

John




More information about the R-help mailing list