hier_import | R Documentation |
This function creates a nested sdc hierarchy from various input structures.
hier_import(inp, from = "json", root = NULL, keep_order = FALSE)
inp |
an object that should be imported. Argument |
from |
(character) from which format should be imported. Possible choices are:
|
root |
optional name of overall total |
keep_order |
if |
a (nested) hierarchy
hier_to_tree()
h <- hier_create(root = "Total", nodes = LETTERS[1:2])
h <- hier_add(h, root = "A", nodes = c("a1", "a2"))
h <- hier_add(h, root = "B", nodes = c("b1", "b2"))
h <- hier_add(h, root = "b1", nodes = "b1a")
hier_display(h)
df <- hier_convert(h, as = "df")
hier_display(df)
h2 <- hier_import(df, from = "df")
hier_display(h2)
# check order
df <- data.frame(
level = c("@", "@@", "@@"),
name = c("T", "m", "f")
)
hier_display(hier_import(df, from = "df")) # automatically sorted (T, f, m)
hier_display(hier_import(df, from = "df", keep_order = TRUE)) # original order (T, m, f)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.