[R] subsetting a data.frame to the 'unique' of a column

Peter Dalgaard p.dalgaard at biostat.ku.dk
Thu Dec 23 12:01:47 CET 2004


Rudi Alberts <r.alberts at rug.nl> writes:


> something like this, however, this gives me the complete df.
> 
> df[df$colname %in% unique(df$colname),]
> 
> or this, which doesnt work
> 
> df[df$colname == unique(df$colname),]


 df[!duplicated(df$colname),]


-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)             FAX: (+45) 35327907




More information about the R-help mailing list