class_vecvec() constructs a new vecvec object from a list of vectors. It is designed to be performant with minimal checks on the inputs. Direct use of class_vecvec() is useful for developers, but for users it is recommended to use vecvec() to create vecvec objects.

class_vecvec(x = list(), i = seq_len(sum(lengths(x))))

Arguments

x

An unnamed list of arbitrary vectors. The vectors can be of different types and lengths, but they must all be vectors (according to vctrs::vec_is). Adjacent vectors of the same type will be combined together into a single vector.

i

A vector of integers specifying the location of each element in x as if they were combined in order. The values in i must be between 1 and the total number of elements across all vectors in x, and can contain duplicates. If not provided, it defaults to a sequence from 1 to the total number of elements across all vectors in x.

Value

A vector of vectors of S7 object of class class_vecvec.

Examples

# Create a vecvec prototype
class_vecvec()
#> <vecvec[0]>

# Construct a vecvec from a list of vectors
class_vecvec(list(letters, rnorm(10)))
#> <vecvec[36]>
#>  [1] a            b            c            d            e           
#>  [6] f            g            h            i            j           
#> [11] k            l            m            n            o           
#> [16] p            q            r            s            t           
#> [21] u            v            w            x            y           
#> [26] z            -1.400043517  0.255317055 -2.437263611 -0.005571287
#> [31]  0.621552721  1.148411606 -1.821817661 -0.247325302 -0.244199607
#> [36] -0.282705449

# Fully specify a vecvec with locations
class_vecvec(
  x = list(letters, rnorm(10)),
  i = c(1:3, 27:31, 26:4, 32:36)
)
#> <vecvec[36]>
#>  [1] a           b           c           -0.55369938  0.62898204  2.06502490
#>  [7] -1.63098940  0.51242695 z           y           x           w          
#> [13] v           u           t           s           r           q          
#> [19] p           o           n           m           l           k          
#> [25] j           i           h           g           f           e          
#> [31] d           -1.86301149 -0.52201251 -0.05260191  0.54299634 -0.91407483