grep_expr {lazy.symbolic} | R Documentation |
grep for expr
Description
Japanese help file: grep_expr_JPH
Usage
grep_expr(expr, varname)
Arguments
expr |
input expression or string |
varname |
a string vector containing variable names to grep |
Value
A list of matches. Each match is a list with components:
- path
An integer vector giving the position of the match within the AST (usable with '[[]]' indexing).
- parent
The parent call object that contains the match.
- match
The matched expression itself.
Examples
expr <- easy_parse("(tr(A %*% B) + A + t(C))")
res <- grep_expr(expr, "A")
length(res) # -> 2. exprの中に"A"はふたつ含まれているので、それぞれの結果
res
# 一つ目のAの結果
expr[[2]][[2]][[2]][[2]][[2]] # res[[1]]$pathの意味
expr[[2]][[2]][[2]][[2]] # res[[1]]$parentの意味
# 2つ目のAの結果
expr[[2]][[2]][[3]] # res[[2]]$pathの意味
expr[[2]][[2]] # res[[2]]$parentの意味
grep_expr(expr, "t(C)")
grep_expr(expr, "A%*%B")
grep_expr(expr, "+")
grep_expr(expr, "(")
grep_expr(expr, "t")
[Package lazy.symbolic version 1.0.0.20250830 ]