Unnest spec is a nested list with the same structure as the
nested json. It specifies how the deeply nested lists ought to be
unnested. spec()
is a handy constructor for spec lists. s()
is a
shorthand alias for spec()
.
spec( selector = NULL, ..., as = NULL, children = NULL, groups = NULL, include = NULL, exclude = NULL, stack = NULL, process = NULL, default = NULL ) s( selector = NULL, ..., as = NULL, children = NULL, groups = NULL, include = NULL, exclude = NULL, stack = NULL, process = NULL, default = NULL )
selector | A shorthand syntax for an
|
---|---|
as | name for this field in the extracted data.frame |
children, ... | Unnamed list of children spec. |
groups | Named list of specs to be processed in parallel. The return
value is a named list of unnested data.frames. The results is the same as
when each spec is |
include, exclude | A list, a numeric vector or a character vector specifying components to include or exclude. A list can combine numeric indexes and character elements to extract. |
stack | Whether to stack this node (TRUE) or to spread it (FALSE). When
|
process | Extra processing step for this element. Either NULL for no processing (the default), "as_is" to return the entire element in a list column, "paste" to paste elements together into a character column. |
default | Default value to insert if the |
s()
: a canonical spec - a list consumed by C++ unnesting routines.
s("a")#> <unnest.spec> #> $ include:"a"s("a//c2")#> <unnest.spec> #> $ include :"a" #> $ children:List of 1 #> ..$ :<unnest.spec> #> .. ..$ children:List of 1 #> .. .. ..$ :<unnest.spec> #> .. .. .. ..$ include:"c2"s("a/2/c2,cid")#> <unnest.spec> #> $ include :"a" #> $ children:List of 1 #> ..$ :<unnest.spec> #> .. ..$ include :2 #> .. ..$ children:List of 1 #> .. .. ..$ :<unnest.spec> #> .. .. .. ..$ include:"c2" "cid"