Given a R expression which represents a sum of terms like
expr <- expression(a + b * c + d + e * f)
I would like to retrieve the set of all the terms of the sum as a list
of names or expressions. So in the example, the elements would be: a
, b * c
, d
and e * f
.
The following comes from a comment.
The tems could themselves contain a +
operator as in
expression(a + b * c + d + e * (f + g))
so we need some understanding of the R language.
Is there a simple way to proceed e.g., using call_tree
of the pryr package?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…