Skip to contents

split vector into list

Usage

split_vector(vector, breaks, bounds = "(]")

Arguments

vector

vector

breaks

split breaks

bounds

"(]" as default, can also be "[), []"

Value

list

Examples

split_vector(1:10, c(3, 7))
#> [[1]]
#> [1] 1 2 3
#> 
#> [[2]]
#> [1] 4 5 6 7
#> 
#> [[3]]
#> [1]  8  9 10
#> 
split_vector(stringr::str_split("ABCDEFGHIJ", "") %>% unlist(),
  c(3, 7),
  bounds = "[)"
)
#> [[1]]
#> [1] "A" "B"
#> 
#> [[2]]
#> [1] "C" "D" "E" "F"
#> 
#> [[3]]
#> [1] "G" "H" "I" "J"
#>