smart.expression {VGAM} | R Documentation

## S Expression for Smart Functions

### Description

`smart.expression` is an S expression for a smart function to call itself. It is best if you go through it line by line, but most users will not need to know anything about it. It requires the primary argument of the smart function to be called `"x"`.

The list component `match.call` must be assigned the value of `match.call()` in the smart function; this is so that the smart function can call itself later.

### See Also

`match.call`.

### Examples

    "my2" <- 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")) {
            return(eval(smart.expression))
        } else
        if(smart.mode.is("write"))
            put.smart(list(minx=minx, match.call=match.call()))
        (x-minx)^2
    }
    attr(my2, "smart") <- TRUE

[Package VGAM version 0.7-9 Index]