.smart.prediction
in
smartpredenv
(R)
or
frame 1 (S-PLUS).put.smart(smart)
.smart.prediction.counter
in
smartpredenv
(R)
or
frame 1 (S-PLUS)
is incremented beforehand,
and .smart.prediction[[.smart.prediction.counter]]
is
assigned the list smart
.
If the list .smart.prediction
in
smartpredenv
(R)
or
frame 1 (S-PLUS)
is not long enough
to hold smart
, then it is made larger, and the variable
.max.smart
in
smartpredenv
(R)
or
frame 1 (S-PLUS)
is adjusted accordingly.put.smart
is used in "write"
mode within a smart function.
It saves parameters at the time of model fitting, which are
later used for prediction.
The function put.smart
is the opposite of
get.smart
, and both deal with the same contents.get.smart
."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