Skip to content
Prev 247880 / 398503 Next

Identify duplicate numbers and to increase a value

Hi John,

If you only have one duplicated number (e.g., just 2), then this will work:

x <- c(1,2,3,5,6,2,8,9,2,2)
xd <- duplicated(x)
x[xd] <- x[xd] + seq(sum(xd))/100
x

otherwise, I think a different framework than duplicated() will be
necessary, because it will matter not just if the number is duplicated
but which one how many times and where.

Cheers,

Josh
On Thu, Jan 20, 2011 at 7:12 AM, Ortiz, John <OrtizJ at si.edu> wrote: