rk.JS.options: Combine several options in one JavaScript variable

View source: R/rk.JS.options.R

rk.JS.optionsR Documentation

Combine several options in one JavaScript variable

Description

Combine several options in one JavaScript variable

Usage

rk.JS.options(
  var,
  ...,
  collapse = ", ",
  option = NULL,
  funct = NULL,
  array = TRUE,
  opt.sep = ", ",
  .ite = list(...)
)

Arguments

var

Character string, name of the JavaScript variable to use in the script code.

...

A list of objects of class rk.JS.ite (see ite). Use the thenjs element to define only the value to add to the option, without commas (e.g., "paired=TRUE" or qp("conf.level=\"", conflevel, "\"").

collapse

Character string, how all options should be concatenated on the R code level (if array=FALSE), or how option should be added to the generated R code. Hint: To place each option in a new line with tab indentation, set collapse=", \\n\\t".

option

A character string, naming, e.g., an option of an R function which should be constructed from several variables. Only used if array=TRUE.

funct

Character string, name of the R function to be called to combine the options, e.g. "list" for list(), or "c" for c(). Set to NULL to drop. Only used if array=TRUE.

array

Logical, if TRUE will generate the options as an array, otherwise in one concatenated character string (probably only useful for mandatory options).

opt.sep

Character string, will be printed in the resulting R code before the option name.

.ite

Like ..., if you have all objects in a list already.

Value

An object of class rk.JS.opt, use rk.paste.JS on that.

See Also

rk.JS.array, and the Introduction to Writing Plugins for RKWard

Examples

# create two checkboxes for independent options
checkA <- rk.XML.cbox(label="Run Test A", value="A")
checkB <- rk.XML.cbox(label="Run it fast", value="true")
# combine them into one JavaScript options variable
rk.JS.options("optionsTestA",
  ite(checkA, qp("test=\"", checkA, "\"")),
  ite(checkB, "fast=TRUE")
)

rkward-community/rkwarddev documentation built on May 9, 2022, 3:02 p.m.