Learn R Programming

VGAM (version 0.8-7)

get.smart: Retrieve One Component of ``.smart.prediction''

Description

Retrieve one component of the list .smart.prediction from smartpredenv (R) or frame 1 (S-PLUS).

Usage

get.smart()

Arguments

Value

  • Returns with one list component of .smart.prediction from smartpredenv (R) or frame 1 (S-PLUS), in fact, .smart.prediction[[.smart.prediction.counter]]. The whole procedure mimics a first-in first-out stack (better known as a queue).

Side Effects

The variable .smart.prediction.counter in smartpredenv (R) or frame 1 (S-PLUS) is incremented beforehand, and then written back to smartpredenv (R) or frame 1 (S-PLUS).

Details

get.smart is used in "read" mode within a smart function: it retrieves parameters saved at the time of fitting, and is used for prediction. get.smart is only used in smart functions such as poly; get.smart.prediction is only used in modelling functions such as lm and glm. The function get.smart gets only a part of .smart.prediction whereas get.smart.prediction gets the entire .smart.prediction.

See Also

get.smart.prediction.

Examples

Run this code
"my1" <- function(x, minx = min(x)) { # Here is a smart function
    x <- x  # Needed for nested calls, e.g., bs(scale(x))
    if(smart.mode.is("read")) {
        smart  <- get.smart()
        minx <- smart$minx          # Overwrite its value
    } else
    if(smart.mode.is("write"))
        put.smart(list(minx = minx))
    sqrt(x-minx)
}
attr(my1, "smart") <- TRUE

Run the code above in your browser using DataLab