# linfun: Function on a Linear Network

### Description

Create a function on a linear network.

### Usage

 `1` ``` linfun(f, L) ```

### Arguments

 `f` A `function` in the R language. `L` A linear network (object of class `"linnet"`) on which `f` is defined.

### Details

This creates an object of class `"linfun"`. This is a simple mechanism for handling a function defined on a linear network, to make it easier to display and manipulate.

`f` should be a `function` in the R language, with formal arguments `f(x,y,seg,tp)` or `f(x,y,seg,tp, ...)` where `x,y` are Cartesian coordinates of locations on the linear network, `seg, tp` are the local coordinates, and `...` are optional additional arguments.

The function `f` should be vectorised: that is, if `x,y,seg,tp` are numeric vectors of the same length `n`, then `v <- f(x,y,seg,tp)` should be a vector of length `n`.

`L` should be a linear network (object of class `"linnet"`) inside which the function `f` is well-defined.

The result is a function `g` in the R language which belongs to the special class `"linfun"`. This function can be called as `g(X)` where `X` is an `"lpp"` object, or called as `g(x,y)` or `g(x,y,seg,tp)` where `x,y,seg,tp` are coordinates. There are several methods for this class including `print`, `plot` and `as.linim`.

### Value

A function in the R\ language. It also belongs to the class `"linfun"` which has methods for `plot`, `print` etc.

### Author(s)

and \rolf

`methods.linfun` for methods applicable to `"linfun"` objects.

`distfun.lpp`, `nnfun.lpp`.

### Examples

 ```1 2 3 4 5``` ``` f <- linfun(function(x,y,seg,tp) { x+y }, simplenet) plot(f) X <- runiflpp(3, simplenet) plot(X, add=TRUE, cex=2) f(X) ```

Search within the spatstat package
Search all R packages, documentation and source code

Questions? Problems? Suggestions? or email at ian@mutexlabs.com.

Please suggest features or report bugs with the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.