Arguments
- x
An atomic vector (e.g.,
character
,integer
,numeric
,factor
,POSIXct
).- index
An integerish
numeric
object or aninteger
object with the indexes/cutting points.- between
(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
).- rm_start
(optional) a
logical
value indicating if the start element of the cut must be removed (default:FALSE
).- rm_end
(optional) a
logical
value indicating if the end element of the cut must be removed (default:FALSE
).
Value
A list
object with the cut pieces as elements.
Details
cutter()
can perform different kinds of cuts. Here are some examples.
See also
Other vector functions:
rm_caps()
,
split_by_pattern()
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
#>