Learn R Programming

Jmisc (version 0.3.1.1)

splitBy: Split a vector by a sequence of length

Description

Split a vector by a sequence of length This function will split the vector x into length(x) subvector. The length of each subvector is given by by.

Usage

splitBy(x, by)

Arguments

x

A vector to be splitted

by

A vector of length

Value

a list of subvector

Examples

Run this code
# NOT RUN {
splitBy((1:10)*10,c(2,2))
splitBy((1:10)*10,c(2,3,4))
# }
# NOT RUN {
expect_equivalent(splitBy((1:10)*10,c(2,2)) ,  list(c(10,20),c(30,40)))
expect_equivalent(splitBy((1:10)*10,c(2,3,4)) , list( c(10,20), c(30,40,50) ,c(60,70,80,90)  ))
# }

Run the code above in your browser using DataLab