# NOT RUN {
x <- list(
list(id = "a", val = 2),
list(
id = "b",
val = 1,
children = list(
list(id = "b1", val = 2.5),
list(
id = "b2",
val = 8,
children = list(
list(id = "b21", val = 4)
)
)
)
),
list(
id = "c",
val = 8,
children = list(
list(id = "c1"),
list(id = "c2", val = 1)
)
)
)
# Basic usage
tree(x)
# Even cleaner output can be achieved by not printing indices
tree(x, index_unnamed = FALSE)
# Limit depth if object is potentially very large
tree(x, max_depth = 2)
# You can customize how the values and classes are printed if desired
tree(x, val_printer = function(x) {
paste0("_", x, "_")
})
# }
Run the code above in your browser using DataLab