[R] using the function unique(), but asking it to ignore a column of a data.frame

hadley wickham h.wickham at gmail.com
Mon Jul 9 16:16:58 CEST 2007

On 7/9/07, Peter Dalgaard <P.Dalgaard at biostat.ku.dk> wrote:
> Andrew Yee wrote:
> > Thanks.  But in this specific case, I would like the output to include
> > all three columns, including the "ignored" column (in this case, I'd
> > like it to ignore column a).
> >
> df[!duplicated(df[,c("a","c")]),]
> or perhaps
> df[!duplicated(df[-2]),]

Yes - of course.  I was momentarily confused about unique vs. duplicated.  Oops!


More information about the R-help mailing list