Description Usage Arguments Details Value References See Also Examples
Split formulas, call and expressions into terms.
1 | split_terms(x, recursive = FALSE)
|
x |
object to split terms from |
recursive |
logical; whether to split terms recursively in parenthetical enclosed terms (depth-first). (Default: FALSE) |
Unlike the [terms()] function, 'split_terms' does not use [stats::terms()] and instead just splits 'x' into an **expression vector** of terms. (Terms are the mathematical notion of terms). The signs of the terms are preserved.
If 'recursive' is 'TRUE', splitting occurs recursively, i.e. parsing of the input descends into parenthetical expressions '(...)'.
See **examples**.
experession vector of terms
* [SO: How to split a formula](https://stackoverflow.com/questions/39155701/how-to-split-a-formula-in-r)
* [terms()]
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
split_terms(1) # 1
split_terms( quote(a) ) # a
split_terms( quote(-a) ) # -a
split_terms( quote(a+1) ) # a, 1
split_terms( quote(1+a) ) # 1, a
split_terms( quote(-1+a) ) # -1, a
split_terms( quote(-1-a) )
split_terms( quote(a+b+c) ) # a,b,c
split_terms( quote((a+b)+1) ) # (a+b),1
split_terms( quote((a+b)+1), recursive=TRUE ) # a,b,1
split_terms( quote((a-b)+1), recursive=TRUE ) # a,-b,1
split_terms( quote(-a) ) # -a
split_terms( quote(a-1) ) # a, -1
split_terms( quote(-a-1)) # -a, -1
split_terms( quote( -(a+1) ) ) # -(a+1)
split_terms( quote( -(a+1) ), recursive=TRUE ) # -a,-1
split_terms( quote( ---a ))
split_terms( quote( -(a+(b-(c+d)))), recursive=TRUE )
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.