https://github.com/cran/spatstat
Tip revision: 2af0235a57146624ae8d5b148d47d8d0ab351213 authored by Adrian Baddeley on 14 May 2007, 05:36:09 UTC
version 1.11-5
version 1.11-5
Tip revision: 2af0235
options.R
#
# options.R
#
# Spatstat Options
#
# $Revision: 1.6 $ $Date: 2007/02/16 07:14:30 $
#
#
".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)
}