https://github.com/cran/spatstat
Tip revision: e04d5b52846caef810a58cd5e19ccbc930c83d14 authored by Adrian Baddeley on 27 October 2007, 05:15:04 UTC
version 1.12-2
version 1.12-2
Tip revision: e04d5b5
options.R
#
# options.R
#
# Spatstat Options
#
# $Revision: 1.7 $ $Date: 2007/10/24 09:41:15 $
#
#
".Spatstat.Options" <-
list(npixel = 100,
maxedgewt=100.0,
par.binary=list(),
par.persp=list(),
par.points=list(),
par.contour=list(),
ndummy.min=25
)
"spatstat.options" <-
function (...)
{
called <- list(...)
if(length(called) == 0)
return(.Spatstat.Options)
if(is.null(names(called)) && length(called)==1) {
# spatstat.options(x)
x <- called[[1]]
if(is.null(x))
return(.Spatstat.Options) # spatstat.options(NULL)
if(is.list(x))
called <- x
}
if(is.null(names(called))) {
# spatstat.options("par1", "par2", ...)
ischar <- unlist(lapply(called, is.character))
if(all(ischar)) {
choices <- unlist(called)
ok <- choices %in% names(.Spatstat.Options)
if(!all(ok))
stop(paste("Unrecognised option(s):", called[!ok]))
if(length(called) == 1)
return(.Spatstat.Options[[choices]])
else
return(.Spatstat.Options[choices])
} else {
wrong <- called[!ischar]
offending <- unlist(lapply(wrong,
function(x) { y <- x;
deparse(substitute(y)) }))
offending <- paste(offending, collapse=",")
stop(paste("Unrecognised mode of argument(s) [",
offending,
"]: should be character string or name=value pair"))
}
}
# spatstat.options(name=value, name2=value2,...)
assignto <- names(called)
if (is.null(assignto) || any(assignto == ""))
stop("options must all be identified by name=value")
ok <- assignto %in% names(.Spatstat.Options)
if(!all(ok))
stop(paste("Unrecognised option(s):", assignto[!ok]))
# reassign
changed <- .Spatstat.Options[assignto]
.Spatstat.Options[assignto] <<- called
# return
invisible(changed)
}