smart.mode.is {VGAM} | R Documentation

## Determine What Mode the Smart Prediction is In

### Description

Determine which of three modes the smart prediction is currently in.

### Usage

    smart.mode.is(mode.arg=NULL)

### Arguments

`mode.arg` | a character string, either `"read"`, `"write"` or `"neutral"`.

### Details

Smart functions such as `bs` and `poly` need to know what mode smart prediction is in. If it is in `"write"` mode then the parameters are saved to `.smart.prediction` using `put.smart`. If in `"read"` mode then the parameters are read in using `get.smart`. If in `"neutral"` mode then the smart function behaves like an ordinary function.

### Value

If `mode.arg` is given, then either `TRUE` or `FALSE` is returned. If `mode.arg` is not given, then the mode (`"neutral"`, `"read"` or `"write"`) is returned. Usually, the mode is `"neutral"`.

### See Also

`put.smart`, `bs`, `poly`.

### Examples

    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

    smart.mode.is()   # Returns "neutral"
    smart.mode.is(smart.mode.is())  # Returns TRUE

[Package VGAM version 0.7-9 Index]