Split a vector into several pieces at given positions.

SplitAt(x, pos)

Arguments

x

the vector to be splitted.

pos

integer vector, giving the positions at which the vector should be splitted.

Value

a list with the splitted parts of x.

Author

flodel (on StackOverflow)

See also

Examples

x <- 1:10
SplitAt(x, pos=c(3, 8))
#> [[1]]
#> [1] 1 2
#> 
#> [[2]]
#> [1] 3 4 5 6 7
#> 
#> [[3]]
#> [1]  8  9 10
#>