call_tree: Display a call (or expression) as a tree.

Description Usage Arguments Examples

View source: R/draw-tree.r

Description

call_tree takes a quoted expression. ast does the quoting for you.

Usage

1
2
3
call_tree(x, width = getOption("width"))

ast(x)

Arguments

x

quoted call, list of calls, or expression to display

width

displays width, defaults to current width as reported by getOption("width")

Examples

1
2
3
4
5
6
7
8
call_tree(quote(f(x, 1, g(), h(i()))))
call_tree(quote(if (TRUE) 3 else 4))
call_tree(expression(1, 2, 3))

ast(f(x, 1, g(), h(i())))
ast(if (TRUE) 3 else 4)
ast(function(a = 1, b = 2) {a + b})
ast(f()()())

Example output

\- ()
  \- `f
  \- `x
  \-  1
  \- ()
    \- `g
  \- ()
    \- `h
    \- ()
      \- `i 
\- ()
  \- `if
  \-  TRUE
  \-  3
  \-  4 
\-  1

\-  2

\-  3 
\- ()
  \- `f
  \- `x
  \-  1
  \- ()
    \- `g
  \- ()
    \- `h
    \- ()
      \- `i 
\- ()
  \- `if
  \-  TRUE
  \-  3
  \-  4 
\- ()
  \- `function
  \- []
    \ a = 1
    \ b = 2
  \- ()
    \- `{
    \- ()
      \- `+
      \- `a
      \- `b
  \- []
 
\- ()
  \- ()
    \- ()
      \- `f 

pryr documentation built on May 2, 2019, 9:58 a.m.