Character Vector to Formula
v2frm
converts a character vector to a formula. The formula has the
simple structure of y ~ x1 + x2 + x3 + ... + xn. This function is a simple
wrapper for reformulate
.
v2frm(v, y = 1L, intercept = TRUE)
v |
character vector of term(s) and/or response to be included on either
side of the returned formula. If it is not a character vector (e.g., factor,
numeric vector), then it is coerced to a character vector within |
y |
character vector of length 1 specifying the value of the element
within |
intercept |
logical vector of length 1 specifying whether the intercept should be included in the returned formula. The default is TRUE and no change is made to the returned formula. If FALSE, then a -1 is added to the end of the right hand side. |
formula with element v[y]
on the left hand side and v[-y]
elements on the right hand side (rhs) separated by plus signs (+) with a -1
if intercept
= FALSE.
v2frm(v = names(attitude)) v2frm(v = names(attitude), y = 7L) v2frm(v = names(attitude), y = NULL) v2frm(v = "rating", y = NULL) try_expr(v2frm(v = "rating")) # error is returned
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.