Package 'codeUtils'

Title: Helper functions for parsing and classifying R code. Useful for domain specific languages.
Description: Very preliminary. May completely change
Authors: Sebastian Kranz
Maintainer: Sebastian Kranz <[email protected]>
License: GPL >= 2.0
Version: 0.1
Built: 2024-11-30 05:48:34 UTC
Source: https://github.com/skranz/codeUtils

Help Index


Find the number of functions and variables (counting multiplies) in a call

Description

Find the number of functions and variables (counting multiplies) in a call

Usage

call.size(call)

Arguments

call

the call whose size shall be determined

Value

an integer of this size


Count all variables appeareances of each variable in a call or expression object

Description

Count all variables appeareances of each variable in a call or expression object

Usage

count.variables(call)

Arguments

a

call object

Value

table that counts variable names


extracts from a call expression its variable and its index

Description

extracts from a call expression its variable and its index

Usage

extract.var.with.index(call, as.character = FALSE)

Find all function calls from a call or expression object

Description

Find all function calls from a call or expression object

Usage

find.funs(call, max.level = Inf, level = 1)

Value

unique names of called functions as character vector


Find all globale variables in a function

Description

just a wrapper to codetools::findGlobals

Usage

find.global.vars(fun)

Find all variables from a call or expression object. If a variable appears n times, it is returned n times

Description

Find all variables from a call or expression object. If a variable appears n times, it is returned n times

Usage

find.multiple.variables(call)

Arguments

a

call object

Value

variables names (possibly duplicated) as character vector


Find all variables from a call or expression object

Description

Find all variables from a call or expression object

Usage

find.variables(call)

Value

unique variables names as character vector


get lhs of an assignment

Description

get lhs of an assignment

Usage

get.lhs(call)

get rhs of an assignment

Description

get rhs of an assignment

Usage

get.rhs(call)

check if a call is an assignment

Description

check if a call is an assignment

Usage

is.assignment(call)

Creates a call with name name and arguments in arg.list

Description

Creates a call with name name and arguments in arg.list

Usage

make.call(name, arg.list, use.names = !is.null(names(arg.list)))

Recursively replace elements of a call or list

Description

Recursively replace elements of a call or list

Usage

recursively.replace(call, replace.fun)

strip a call object from outer parentheses

Description

strip a call object from outer parentheses

Usage

strip.parentheses(call, parentheses = "(")

Substitute a variable or a symbol in the expression by subs

Description

Substitute a variable or a symbol in the expression by subs

Usage

subst.var(call, var, subs, subset = TRUE)

Arguments

call

a call object or string

var

a symbol or string

subs

a call or string


substitutes in a call object x (works like substitute2 in pryr)

Description

substitutes in a call object x (works like substitute2 in pryr)

Usage

substitute.call(x, env)