atable (version 0.1.0)

replace_consecutive: Replaces consecutive elements

Description

If x[i+1]=x[i] then x[i+1] is replaced by by for i=1,...length(x)-1.

Usage

replace_consecutive(x, by = "")

Arguments

x

A character or factor.

by

A character with length 1.

Value

A character, same length as x, now with consecutives replaced by by. If length(x) < 2, x is returned unchanged.

Details

The = is defined by function identical.

Examples

Run this code
# 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