earth (version 0.1-2)

format.earth: Format 'earth' objects

Description

Return a string representing the earth expression.

Usage

## S3 method for class 'earth':
format(x = stop("no 'x' arg"),
       digits = getOption("digits"), use.names = TRUE,
       add.labels = FALSE,  decomp = "anova",  ...)

Arguments

x
An earth object. This is the only required argument.
digits
Number of significant digits. The default is getOption(digits).
use.names
If TRUE (default), use variable names. Else use names of the form x[,1].
add.labels
If TRUE add comments numbering each term. The default is FALSE.
decomp
One of "anova" (the default) order the terms using the anova decomposition i.e. in increasing order of interaction "none" order the terms as created during the earth forward pass.
...
Unused, but provided for generic/method consistency.

Value

  • A character representation of the earth object.

See Also

earth, pmax

Examples

Run this code
a <- earth(Volume ~ ., data = trees)
cat(format(a))

# yields:
#      23.20824
#      +  5.745962 * pmax(0,  Girth -   12.9)
#      -  2.866452 * pmax(0,   12.9 -  Girth)
#      + 0.7183364 * pmax(0, Height -     76)

cat(format(a, use.names = FALSE, add.labels = TRUE))

# yields:
#      23.20824  # 1
#      +  5.745962 * pmax(0, x[,1] -  12.9)  # 2
#      -  2.866452 * pmax(0,  12.9 - x[,1])  # 3
#      + 0.7183364 * pmax(0, x[,2] -    76)  # 4

Run the code above in your browser using DataCamp Workspace