get_recursive_index: Obtain an index to extract out a sub-call

Description Usage Arguments Value Examples

View source: R/tree_routines.R

Description

Obtains an index that can be used to extract a sub-call from a language object.

Usage

1
get_recursive_index(th, node_id)

Arguments

th

A TreeHarp object.

node_id

An integer corresponding to a call within the parse tree (not a literal, symbol or a formal argument).

Value

A vector of indices, that can be used (together with "[[") to obtain a sub-call

Examples

1
2
3
4
5
ex3 <- quote(x <- f(y = g(3, 4), z=1L))
t1 <- TreeHarp(ex3, TRUE)
rec_index <- get_recursive_index(t1, 6)
ex3[[rec_index + 1]]
ex3[[get_recursive_index(t1, 3)+1]]

autoharp documentation built on Nov. 13, 2021, 1:06 a.m.