Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

create_node_from_nested_root

Convert a nested tibble into a node tree


Description

This function is convenient to display all nesting levels of a nested tibble at once.

Usage

create_node_from_nested_root(pd_nested, structure_only)

Arguments

pd_nested

A nested tibble.

structure_only

Whether or not create a tree that represents the structure of the expression without any information on the tokens. Useful to check whether two structures are identical.

Value

An object of class "Node" and "R6".

Examples

if (rlang::is_installed("data.tree")) {
  withr::with_options(
    list(styler.cache_name = NULL), # temporarily deactivate cache
    {
      code <- "a <- function(x) { if(x > 1) { 1+1 } else {x} }"
      nested_pd <- styler:::compute_parse_data_nested(code)
      initialized <- styler:::pre_visit(nested_pd, c(default_style_guide_attributes))
      styler:::create_node_from_nested_root(initialized, structure_only = FALSE)
    }
  )
}

styler

Non-Invasive Pretty Printing of R Code

v1.4.1
MIT + file LICENSE
Authors
Kirill Müller [aut], Lorenz Walthert [cre, aut]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.