rk.JS.array: Create a simple JavaScript array

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

rk.JS.arrayR Documentation

Create a simple JavaScript array

Description

If you need to combine multiple options (like values of several checkboxes) into one vector or list, this function can help with that task. All relevant variables will become part of an array and then joined into the desired argument type.

Usage

rk.JS.array(
  option,
  variables = list(),
  funct = "c",
  var.prefix = NULL,
  quote = FALSE,
  opt.sep = ", "
)

Arguments

option

A character string, naming, e.g., an option of an R function which should be constructed from several variables.

variables

A list with either character strings (the names of the variables to combine to a vector or list), or objects of class XiMpLe.node with plugin XML nodes (whose ID will be extracted and used).

funct

Character string, name of the R function to be called to combine the options, e.g. "list" for list(), or "c" for c().

var.prefix

A character string. sets a global string to be used as a prefix for the JS variable names.

quote

Logical, if TRUE, the values will be quoted in the resulting R code (might be neccessary for character values).

opt.sep

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

Value

An object of class rk.JS.arr.

See Also

rk.paste.JS, rk.JS.options, rk.JS.vars, echo, id, and the Introduction to Writing Plugins for RKWard

Examples

# create three checkboxes for independent options
checkA <- rk.XML.cbox(label="Run Test A", value="A")
checkB <- rk.XML.cbox(label="Run Test B", value="B")
checkC <- rk.XML.cbox(label="Run Test C", value="C")
# combine them into one list of options via JavaScript
rk.JS.array("run.tests", variables=list(checkA, checkB, checkC), funct="list")

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