These functions allow generic list behaviour.
Usage
# S3 method for class 'struct_list'
c(...)
# S3 method for class 'struct_list'
rep(x, ...)
# S3 method for class 'struct_list'
x$y
# S3 method for class 'struct_list'
x[...]
# S3 method for class 'struct_list'
x[...] <- value
# S3 method for class 'struct_list'
x[[...]]
# S3 method for class 'struct_list'
x[[...]] <- value
Functions
c(struct_list)
: Repeat a `struct_list`rep(struct_list)
: Repeat a `struct_list`$
: Subset a `struct_list`[
: Subset a `struct_list``[`(struct_list) <- value
: Assign a subset to a `struct_list`[[
: get a value from a `struct_list``[[`(struct_list) <- value
: set a single value in a `struct_list`
Examples
x = struct(a=1,b=2,c=1:3,.class="test")
y = struct(a=4,b=5,c=1:3,.class="test")
z= tibble::tibble(a= 1:10, b=rep(c(x,y),5))
z$b
#> test(a, b, c)
#> 1, 2, 1, 2, 3 4, 5, 1, 2, 3 1, 2, 1, 2, 3 4, 5, 1, 2, 3 1, 2, 1, 2, 3 4, 5, 1, 2, 3 1, 2, 1, 2, 3 4, 5, 1, 2, 3 1, 2, 1, 2, 3 4, 5, 1, 2, 3
c(x,y)
#> test(a, b, c)
#> 1, 2, 1, 2, 3 4, 5, 1, 2, 3
c(rep(x,5),y)
#> test(a, b, c)
#> 1, 2, 1, 2, 3 1, 2, 1, 2, 3 1, 2, 1, 2, 3 1, 2, 1, 2, 3 1, 2, 1, 2, 3 4, 5, 1, 2, 3
class(c(rep(x,5),rep(y,5))[[1]])
#> [1] "test" "struct"
as.struct_list(list(x,y))
#> test(a, b, c)
#> 1, 2, 1, 2, 3 4, 5, 1, 2, 3
#' x = struct(a=1,b=2,c=1:3,.class="test")
class(rep(c(x,y),5)[[1]]) == "test"
#> [1] TRUE FALSE
class(rep(x,5))
#> [1] "struct_list" "list" "test"
a = (rep(c(x,y),5))
a[[1]] = y
a
#> test(a, b, c)
#> 4, 5, 1, 2, 3 4, 5, 1, 2, 3 1, 2, 1, 2, 3 4, 5, 1, 2, 3 1, 2, 1, 2, 3 4, 5, 1, 2, 3 1, 2, 1, 2, 3 4, 5, 1, 2, 3 1, 2, 1, 2, 3 4, 5, 1, 2, 3