View source: R/standalone-struct-list.R
struct | R Documentation |
Create a structure.
struct(..., .class = NULL, .attr = list())
is.struct(x, .class = NULL)
as.struct(x, .class)
## S3 method for class 'struct'
as.list(x, ...)
is.struct_list(x, .class = NULL)
... |
a set of named values to use in the structure. or an unnamed list of 'struct's of the same type |
.class |
the class of the nested list |
.attr |
attributes to assign to the structure |
Usually a length one 'struct_list' with a single 'struct' item with class '.class' and attributes '.attr'. If a list of 'struct's is provided then it will be longer than 1.
as.list(struct)
: Make 'struct' into plain list
is.struct()
: Check is a 'struct'
as.struct()
: Cast to a 'struct'
is.struct_list()
: is a list of 'structs'?
x = struct(a=1,b=2,c=1:3,.class="test")
format.test = function(x,...) {sprintf("\"%d/%d [%d-%d]\"", x$a, x$b, min(x$c), max(x$c))}
x # is a struct_list of length 1
x[[1]] # is a struct of length 1
# e = struct(.class="test")
try(struct())
x =
struct(
struct(a=1,b=2,c=1:3,.class="test"),
struct(a=2,b=3,c=4:5,.class="test")
)
tmp = lapply(1:10, function(x) struct(a=x,b=3,c=4:5,.class="test"))
struct(tmp)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.