delete.response
Modify Terms Objects
Description
Modifies terms objects to remove a response
or variables of the model formula, or
creates a formula from character vectors (reformulate).
Usage
delete.response(termobj)
drop.terms(termobj, dropx = NULL, keep.response = FALSE)
reformulate(termlabels, response = NULL, intercept = TRUE, env = parent.frame())
## S3 method for class 'terms':
x[i]
Arguments
termobj |
an object of class c("terms", "formula").
|
dropx |
a numeric vector. Indicates the position of items in attr(termobj, "term.labels")
to drop.
|
keep.response |
a logical value. If TRUE, keeps the response component of termobj.
The default is FALSE.
|
response |
a character string. Used as the left-hand side of a model formula.
|
termlabels |
a character vector of a length of at least one. Indicates the right-hand side of a model formula.
If termlabels specifies any variables names that include spaces, or are otherwise not parsed by R as names, enclose
them with backticks.
|
intercept |
a logical value. If TRUE (the default), the function has an intercept for the formula.
If FALSE, add "-1" to the right-hand side of a model formula.
|
i |
subscript expressions used to identify the elements to extract or replace.
|
env |
the environment to attach to the formula that is created by reformulate.
|
Value
delete.response |
returns a "terms" object like termsobj but without response.
|
drop.terms |
returns a "terms" object like termsobj with the designated variables.
|
reformulate |
returns a formula composed of termlabels and response, connected with "~".
|
"[.terms" |
returns a new "terms" object,
composed of designated labels and the original response.
|
See Also
Examples
f.fit <- y ~ X1 + X2 + X3
t.fit <- terms(f.fit)
delete.response(t.fit)
drop.terms(t.fit, drop = 1:2, keep.response = FALSE)
reformulate(c("a", " b", "c"), "y", intercept = FALSE)
reformulate(c("a", " b", "c"), intercept = TRUE)
t.fit[1:2]
t.fit[-2]