Description Usage Arguments Examples
Some functions to make it easier to build and minipulate formulas
1 2 3 4 5 6 7 8 9 | build_formula(lhs, rhs, env = parent.frame(), op = "+")
keep_summands(formula, n, right = TRUE, env = environment(formula),
op = "+")
summands(formula, n, right = TRUE, op = "+")
replace_summand(formula, n, term, right = TRUE, op = "+",
env = environment(formula))
|
lhs, rhs |
list or vector of character strings containing summands for left and right hand sides
of a formula. |
env |
an environment to attach to the formula |
op |
The operator to use for splitting into terms. |
formula |
a formula |
n |
a vector of integer indices. Negatives can be used to deselect. |
right |
a logical indicating whether to operate on the right side (else the left) of the formula. |
term |
a character string containing a new term |
1 2 3 4 5 6 7 8 9 10 11 12 | a <- build_formula(c("a", "b"), c("x", "y", "log(x*y)")); a
b <- build_formula("response", list("x", "y", NULL, "log(x)"), op="*"); b
f <- build_formula( "iGDP", list("iK", "iL", "iQp", "iYear")); f
g <- build_formula( "iGDP", c("iK", "iL", "iQp", "iYear")); g
identical(f,g)
summands(a)
summands(a, right=FALSE)
summands(b, op="*")
keep_summands(f, 3)
keep_summands(f, -3)
keep_summands(f, 2:4)
h <- replace_summand( f, 3, paste(summands(f, 3), lhs(f), sep="/")); h
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.