> -----Original Message----- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] > On Behalf Of [EMAIL PROTECTED] > Sent: Thursday, August 14, 2008 2:00 PM > To: r-help@r-project.org > Subject: [R] Detecting duplicate values > > This is another "how do I do it" type of question. It seems that for a > function that I have it has a hard time with lists that have a single > repeated value. I want a function (or expression) that will detect this > condition. I want to detect: > > c(2,2,2,2,2) > OR > c(1) > > The following is OK > > c(2,3,3,2) > OR > c(1,2,1) > > These lists are "OK" because they have another value in the list. In other > words I want to detect if there is only one element in the list that > repeats 1 or more times. > > Will length(table(a)) = 1 always work? If so I have answered my own > question. If not please bear with me as I have missed a case.
Consider also length(unique(a)) == 1 Steve McKinney > > Thank you. > > Kevin > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting- > guide.html > and provide commented, minimal, self-contained, reproducible code. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.