Transfer a vector to a list

vec2list(y_int, nvec)

Arguments

y_int

a vector with length n.

nvec

an integer vector, specify the length of each component in the transferred list. n=sum(nvec).

Value

return a list with each component vector

Examples

vec2list(c(rep(1,3), rep(2, 5)), nvec=c(3, 5))
#> [[1]]
#> [1] 1 1 1
#> 
#> [[2]]
#> [1] 2 2 2 2 2
#>