Keep elements in a vector sequence, and replace the rest with ""
Usage
str_keep_seq(x, ..., by = 2, offset = 0)
Arguments
- x
A vector.
- ...
If numeric, other arguments passed to the scales::comma function.
- by
The increment of elements to keep. Defaults to 2.
- offset
An offset to start at the intended offset. Defaults to 0. Possible values are -1 to (by
- 2)
Examples
x <- LETTERS[1:12]
str_keep_seq(x)
#> [1] "A" "" "C" "" "E" "" "G" "" "I" "" "K" ""
str_keep_seq(x, offset = -1)
#> [1] "" "B" "" "D" "" "F" "" "H" "" "J" "" "L"
str_keep_seq(x, by = 3)
#> [1] "A" "" "" "D" "" "" "G" "" "" "J" "" ""