Formula operations and coercion as a supplement to update.formula()
formula_add_str(frm1, terms, op = "+")
formula_add(frm1, frm2)
formula_poly(chr1, n, noint = FALSE, y = NULL)
formula_nth(frm1, n)
formula_to_interaction_matrix(frm1)
formula_chr_to_form(rhs, lhs = character(0))
to_str(chr1, collapse = "+")
terms_labels(frm1)
simplify_rhs(object)
# S3 method for class 'formula'
simplify_rhs(object)
# S3 method for class 'character'
simplify_rhs(object)
as_rhs_frm(object)
as_lhs_frm(object)
as_rhs_chr(object, string = FALSE)
as_lhs_chr(object, string = FALSE)
unique_formula(list_of_formulas)
Formulas to be coerced to character vectors.
Character string.
Either "+" (default) or "-".
Character vector to be coerced to formulas.
Positive integer.
Boolean.
Response
right-hand-side and left-hand-side for formula (as characters)
Character to use as separator.
Character vector or formula.
Boolean.
list of formulas
formula_poly("z", 2)
#> ~z + I(z^2)
#> <environment: 0x5e00f318e3c0>
formula_poly("z", 2, noint=TRUE)
#> ~-1 + z + I(z^2)
#> <environment: 0x5e00f3150fb8>
as_rhs_chr(c("a", "b", "z"))
#> [1] "abz"
as_rhs_chr(c("a*b", "z"))
#> [1] "a*bz"
as_rhs_chr(y~a+b+z)
#> [1] "a+b+z"
as_rhs_chr(y~a+b+z, string=TRUE)
#> [1] "a+b+z"
as_rhs_chr(y~a+b+z)
#> [1] "a+b+z"
as_rhs_chr(y~a*b+z)
#> [1] "a+a:b+b+z"
as_rhs_chr(y~a*b+z, string=TRUE)
#> [1] "a+a:b+b+z"
as_lhs_chr(y~a*b+z)
#> [1] "y"
as_lhs_chr(log(y)~a*b+z) ## Not what one might expect
#> [1] "log" "y"
as_lhs_chr(cbind(y, u)~a*b+z) ## Not what one might expect
#> [1] "cbind" "y" "u"
formula_chr_to_form(c("a*b", "z"))
#> ~a * b + z
#> <environment: 0x5e00f19326c8>
formula_chr_to_form(c("a*b", "z"), "y")
#> y ~ a * b + z
#> <environment: 0x5e00f18cbe58>
formula_chr_to_form(c("a*b", "z"), "log(y)")
#> log(y) ~ a * b + z
#> <environment: 0x5e00f1861770>
formula_add(y~a*b+z, ~-1)
#> y ~ a + a:b + b + z
#> <environment: 0x5e00f17e8ad8>
formula_add(y~a*b+z, ~a:b)
#> y ~ a + a:b + b + z
#> <environment: 0x5e00f0851780>
formula_add_str(y~x1 + x2, "x3")
#> y ~ x1 + x2 + x3
#> <environment: 0x5e00f31a4120>
formula_add_str(y~x1 + x2, "x1")
#> y ~ x1 + x2
#> <environment: 0x5e00f31a4120>
formula_add_str(y~x1 + x2, "x1", op="-")
#> y ~ x2
#> <environment: 0x5e00f31a4120>