Create a Terms Object

DESCRIPTION:
This function creates a terms object to use in model fitting. It is returned as a component of the fitted object by the fitting functions lm, etc.

USAGE:
terms(formula, specials, abb = NULL, data, neg.out = T, keep.order = F)
as.terms(object)

REQUIRED ARGUMENTS:
formula:
a formula or an object containing a formula.
specials:
what functions occurring in the formula should be marked as special in the terms object.

OPTIONAL ARGUMENTS:
abb:
optional abbreviations that may have been used in the formula. If included, this should be in the form returned by the abbreviate function; that is, a character vector containing the abbreviations that has a names attribute specifying the full names to be used. If abbreviations are used, all the expanded names will appear everywhere in the terms object.
data:
optional data frame in which to interpret the formula. Only needed if the formula wants to use the special name "." to refer to all the variables in the data frame.
neg.out:
flag controlling the treatment of terms entering with "-" sign. If TRUE, terms will be checked for cancellation and otherwise ignored. If FALSE, negative terms will be retained (with negative order). The latter version is used, for example, in fractionate.
keep.order:
should the terms be kept in the order they are generated. By default, terms are re-ordered so that main effects appear before interactions, etc. This is the desirable version, except for special models that try, for example, to force a multi-way table of means to be the first set of coefficients fit. See the example below.
object:
any object that can define a terms object: a formula, a fitted model, a model matrix, or a terms object itself.

VALUE:
An object of class "terms" describing the formula. See terms.object for its detailed contents. This object drives all the model-fitting and is returned as a component of the fitted object by the fitting functions lm, etc. The object itself is of mode "expression", with one element for each of the terms, after expansion and possible simplification, and not including the intercept.

The function as.terms leaves term objects alone, and converts formula objects, and a variety of objects that contain formulas as components or attributes, by calling terms.


DETAILS:
Returns a terms.object that describes the information about a structural model, as specified by a formula.

SEE ALSO:
aov , terms.object .

EXAMPLES:
terms(Yield~Temp*Conc+Error(blocks),specials="Error")

# Produces the following output: expression(Temp, Conc, Error(blocks), Temp:Conc) attr(, "formula"): Yield ~ Temp * Conc + Error(blocks) attr(, "factors"): Temp Conc Error(blocks) Temp:Conc Yield 0 0 0 0 Temp 1 0 0 1 Conc 0 1 0 1 Error(blocks) 0 0 1 0 attr(, "order"): [1] 1 1 1 2 attr(, "variables"): expression(Yield, Temp, Conc, Error(blocks)) attr(, "term.labels"): [1] "Temp" "Conc" "Error(blocks)" "Temp:Conc" attr(, "intercept"): [1] 1 attr(, "response"): [1] 1 attr(, "specials"): attr(, "specials")$Error: [1] 4

attr(, "class"): [1] "terms"

# an example of keep.order = T aov.with.means <- aov(terms(Weight~Trans1:Trans2+Tires-1, keep.order = T), cu.specs)