50% off | Unlimited Data & AI Learning

Last chance! 50% off unlimited learning

Sale ends in


ggblanket (version 7.0.0)

replace_seq: Replace a sequence of elements in a vector

Description

Keep every nth element in a vector, and replace the rest with a value such as "".

Usage

replace_seq(x, ..., keep_nth = 2, offset = 0, replacement = "")

Value

A vector.

Arguments

x

A vector.

...

If numeric, other arguments passed to the scales::comma function.

keep_nth

The increment of elements to keep as is. Defaults to 2.

offset

An offset to start at the intended offset. Defaults to 0. Possible replaces are -1 to (keep_nth - 2)

replacement

The replacement value to replace non-kept elements with. Defaults to "".

Examples

Run this code
replace_seq(seq(1000, 7000, 1000))
replace_seq(seq(1000, 7000, 1000), offset = -1)
replace_seq(seq(1000, 7000, 1000), keep_nth = 3)
replace_seq(LETTERS[1:12])

Run the code above in your browser using DataLab