If x[i+1]=x[i] then x[i+1] is replaced by by for i=1,...length(x)-1.
x[i+1]=x[i]
x[i+1]
by
i=1,...length(x)-1
replace_consecutive(x, by = "")
A character or factor.
A character with length 1.
A character, same length as x, now with consecutives replaced by by. If length(x) < 2, x is returned unchanged.
x
length(x) < 2
The = is defined by function identical.
=
identical
# NOT RUN { x <- rep(c('a','b','c','d'), times=c(2,4,1,3)) x # } # NOT RUN { replace_consecutive(x) # } # NOT RUN { # }
Run the code above in your browser using DataLab