Skip to content
Prev 305144 / 398506 Next

Identifying duplicate rows?

On Mon, Sep 10, 2012 at 11:23:42AM -0700, kborgmann wrote:
Hi.

Try the following.

  dfA <- cbind(State="VA", data.frame(Value=c(73, 73, 76, 76, 74, 75)))
  dfA$dups <- duplicated(dfA$Value) | duplicated(dfA$Value, fromLast=TRUE)
  dfA

    State Value  dups
  1    VA    73  TRUE
  2    VA    73  TRUE
  3    VA    76  TRUE
  4    VA    76  TRUE
  5    VA    74 FALSE
  6    VA    75 FALSE

Hope this helps.

Petr Savicky.