View source: R/replace_consecutive.R
x[i+1] is replaced by
replace_consecutive(x, by = "", fun_for_identical = base::identical)
A character or factor.
A character with length 1.
A function with two arguments called
= is defined by function
identical by default.
This function can be changed by argument fun_for_identical
A character, same length as
x, now with consecutives replaced by
length(x) < 2, x is returned unchanged.
x <- rep(c('a','b','c','d'), times=c(2,4,1,3)) x ## Not run: replace_consecutive(x) # NA should not be identical. So change fun_for_identical fun_for_identical <- function(x,y) !is.na(x) && !is.na(y) && identical(x,y) x <- c(1,1,3,3,NA,NA, 4) x ## Not run: replace_consecutive(x, by="99") ## Not run: replace_consecutive(x, by="99", fun_for_identical = fun_for_identical)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.