eval.parameters {RandomFields} | R Documentation |
eval.parameters provides an interactive menu on a X11 graphical device of R
eval.parameters(variable, entry, update, simulate, dev, create = TRUE, col.rect = "red", col.bg = "blue", col.sep = "grey", col.left = "red", col.mid = "white", col.right = "white", col.line = "red", col.txt = "black", cex=0.8, cex.i=0.8, sep="-----", ...)
variable |
string. The name of the variable to be changed. The variable must be a list. |
entry |
A list of lists. See Details. |
update |
logical. If TRUE then simulate is called
after each interactive input. |
simulate |
function that is called if simulations are to
updated. The parameters must equal the variables given by
... ; the function must return the first variable. |
dev |
Before calling eval.parameters() split.screen
must have been called. dev gives the screen on which the
interactive menu should be plotted. |
create |
logical. If TRUE missing list elements are created. |
col.rect |
colour of the button for free input. |
col.bg |
colour of a interactive bar |
col.sep |
colour of the separating line |
col.left |
colour of preceding element |
col.mid |
colour for the message |
col.right |
colour of subsequent element |
col.line |
colour of the marking line in interactive bars of absolute choice. |
col.txt |
colour of headers |
cex |
font height of headers |
cex.i |
font height of text for elements |
sep |
style of added characters in separating line. |
... |
The input variables; the name may not start with a dot; the first variable must be a list and is finally returned. |
eval.parameters
shows a menu list on X11. Depending on the
mode of the variables the menu bars have a different appearance and
behave differently if the user clicks on the bar.
Most of the menu bars have a small rectangle on
the right hand side. If this rectangle is pressed the input of a
variable is expected in the xterm where R is run.
entry
is a list of lists. Each list may contain the following
elements:
name
: header for menu button if var
is not NULL
var
:
NULL
: if val=NULL
then
it is a separating line in colour col.sep
;
name
is surrounded by sep
; all other elements of
the list are ignored.
If val
is a string then val
is interpreted as a
function; a special string is "simulate", which entails the call of
the function simulate
with the appropriate parameters.
variable
val
:
function(d, v)
gives the update for
var
. If v
is missing, a starting value (for
d=1/2) is expected. Otherwise, v
is the current value
of var
and d
is the choice of the user,
a value in [0,1]
TRUE
: logical bar. The value for var
is negated.
FALSE
: logical bar. The value for var
is negated.
In the menu, the negative value for var
is shown.
NULL
: Any string expected as value for var
.
var
is given then
this vector of strings is interpreted as belonging to a
categorical variable
1,...,length(val)
and var
gives the names of the elements.
If var=NULL
then val
is interpreted as a function; a
special string is "simulate", which entails the call of
the function simulate
with the appropriate parameters.
delta
: logical.
The bar plots absolute values if FALSE
and increments otherwise. Only considered if val
is a function.
cond
: A condition that must be satisfied; otherwise this
point is not shown.
col
: colour that overwrites the standard colour for the
rectangle or the separating text
...
: additional parameters for simulate
that overwrite
the values given in ...
in the call of eval.parameters
.
The first variable given in “...
”, which is a list.
To this list the entry .history
is added.
If the users enters ‘exit immediately’ at any point, the program
stops with an error message.
To the list given by variable
the element .history
is added. .history
is a list that contains the history
of the user input. Each element is a list where the first entry
is the number of the menu, the second and the third entries are the
former and the new value. Exception: for entries with character
val
, the value of val
is returned as second entry.
Consequently, the name .history
should not be used for other
purposes in variable
.
Further, any variable name given in ...
must start with a letter.
Martin Schlather, martin.schlather@cu.lu http://www.cu.lu/~schlathe
## the following lines define a menu that does not make ## to much sense, but shows the various kinds of buttons quadratic <- function(d, v, a, mini=0, maxi=Inf) { d <- pmin(1, pmax(0, d)) - 0.5 d <- ((d>0) * 2 - 1) * d^2 * a * 4 if (missing(v)) d else pmax(mini, pmin(maxi, v + d)) } simulate <- function(H, par) { ## not a serious example print(c(H$x$var, par, runif(1))) return(H) ## the function must return the first parameter } entry <- list( list(name="Nonsense Menu"), list(name="Simulate!", val="simulate", col="blue"), list(name="show H", val="str(H)", col="blue"), list(name="colx", var="colour", val=c("red", "green", "blue", "brown")), list(name="open", var="closed", val=FALSE, par=4.5), list(name="modifying", var="modify", val=TRUE, par=5), list(name="probability", var="probab", delta=FALSE, val=function(d, v) pmin(1, pmax(0, d))), list(name="variance", var="var", delta=TRUE, val=function(d, v) quadratic(d, v, 10)), list(name="name", var="name", par=3, cond="modify"), ) scr <- split.screen(rbind(c(0, 0.45, 0, 1), c(0.5, 1, 0, 1))) ## before proceeding make sure that both the screen and the xterm ## are completely visible H <- list(modify=5, x=list()) if (.Platform$OS.type=="unix") system("xset b off") ## probably, ## you prefer to switch off the sound str(eval.parameters("H$x", entry, simulate, update=TRUE, dev=scr[2], H=H, par=17)) # do not forget to call by name