Possible Duplicate:
Select only the first rows for each unique value of a column in R
I have a matrix of the following form:
col1 col2
1    2   
1    2    
1    2   
1    2   
1    2
2    5
2    5
2    5
3    7
3    7
3    7
3    7
3    7
3    7
3    7
3    7
4    2 
4    2 
4    2
I would like to select all the unique rows based on 'col1'.
which in this case would be the first row from each unique value in col1:
subset:
col1   col2
1      2 
2      5
3      7
4      2
Here's what I've tried:
https://dl.dropbox.com/u/22681355/matrix.csv
mat<-read.csv("matrix.csv")
sub<-unique(mat$V1)
subset(mat, mat==c(sub)
It spits out much more than I would expect to get and I get this error mesage:
Warning message: In contacts$V1 == c(g) : longer object length is not a multiple of shorter object length
 
     
    