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 |
Find the number of functions and variables (counting multiplies) in a call
call.size(call)
call.size(call)
call |
the call whose size shall be determined |
an integer of this size
Count all variables appeareances of each variable in a call or expression object
count.variables(call)
count.variables(call)
a |
call object |
table that counts variable names
extracts from a call expression its variable and its index
extract.var.with.index(call, as.character = FALSE)
extract.var.with.index(call, as.character = FALSE)
Find all function calls from a call or expression object
find.funs(call, max.level = Inf, level = 1)
find.funs(call, max.level = Inf, level = 1)
unique names of called functions as character vector
just a wrapper to codetools::findGlobals
find.global.vars(fun)
find.global.vars(fun)
Find all variables from a call or expression object. If a variable appears n times, it is returned n times
find.multiple.variables(call)
find.multiple.variables(call)
a |
call object |
variables names (possibly duplicated) as character vector
Find all variables from a call or expression object
find.variables(call)
find.variables(call)
unique variables names as character vector
check if a call is an assignment
is.assignment(call)
is.assignment(call)
Creates a call with name name and arguments in arg.list
make.call(name, arg.list, use.names = !is.null(names(arg.list)))
make.call(name, arg.list, use.names = !is.null(names(arg.list)))
Recursively replace elements of a call or list
recursively.replace(call, replace.fun)
recursively.replace(call, replace.fun)
strip a call object from outer parentheses
strip.parentheses(call, parentheses = "(")
strip.parentheses(call, parentheses = "(")
Substitute a variable or a symbol in the expression by subs
subst.var(call, var, subs, subset = TRUE)
subst.var(call, var, subs, subset = TRUE)
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)
substitute.call(x, env)
substitute.call(x, env)