make.S | R Documentation |
make.S(scrFrame, buffer, res, xy = NULL)
scrFrame |
|
buffer |
|
res |
|
xy |
##---- Should be DIRECTLY executable !! ----
##-- ==> Define data, use random,
##-- or do help(data=index) for the standard data sets.
## The function is currently defined as
function (scrFrame, buffer, res, xy = NULL)
{
if (class(scrFrame) != "scrFrame")
stop("Need an object of class scrFrame to create the state space")
if (is.null(xy))
xy <- c(1, 2)
if (res == NULL)
stop("You didnt provide a resolution value!")
if (res == NULL)
stop("You didnt provide a buffer value!")
S <- list()
trpls <- scrFrame$traps
for (i in 1:length(trpls)) {
bl <- apply(trpls[[i]][, xy], 2, min)
tr <- apply(trpls[[i]][, xy], 2, max)
sxy <- expand.grid(seq(bl[1] - buffer, tr[1] + buffer,
res), seq(bl[2] - buffer, tr[2] + buffer, res))
dd <- apply(e2dist(sxy, trpls[[i]][, xy]), 1, min)
S[[i]] <- sxy[dd <= buffer, ]
}
return(S)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.