cutter(x, index, between = NULL, rm_start = FALSE, rm_end = FALSE)
An atomic vector (e.g.,
character
, integer
, numeric
, factor
, POSIXct
).
An integerish numeric
object
or an integer
object with the indexes/cutting points.
(optional) A string object indicating the direction of the cut
(choices: "left"
, "right"
). This argument only need to be assigned if
the cut must be performed between the indexes values (default: NULL
).
(optional) a logical
value indicating if the
start element of the cut must be removed (default: FALSE
).
(optional) a logical
value indicating if the end
element of the cut must be removed (default: FALSE
).
A list
object with the cut pieces as elements.
cutter()
can perform different kinds of cuts. Here are some examples.
## Cutting by index values
cutter(seq(10), c(3, 9))
#> [[1]]
#> [1] 1 2
#>
#> [[2]]
#> [1] 4 5 6 7 8
#>
#> [[3]]
#> [1] 10
#>
## Cutting between index values
cutter(seq(10), c(3, 9), between = "left")
#> [[1]]
#> [1] 1 2
#>
#> [[2]]
#> [1] 3 4 5 6 7 8
#>
#> [[3]]
#> [1] 9 10
#>
cutter(seq(10), c(3, 9), between = "right")
#> [[1]]
#> [1] 1 2 3
#>
#> [[2]]
#> [1] 4 5 6 7 8 9
#>
#> [[3]]
#> [1] 10
#>
## Removing start or end tips
cutter(seq(10), c(3, 9), rm_start = TRUE)
#> [[1]]
#> [1] 4 5 6 7 8
#>
#> [[2]]
#> [1] 10
#>
cutter(seq(10), c(3, 9), rm_end = TRUE)
#> [[1]]
#> [1] 1 2
#>
#> [[2]]
#> [1] 4 5 6 7 8
#>