Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

asJSVars

Serialize R objects as Javsscript/ActionScript variables


Description

This function takes R objects and serializes them as Javascript/ActionScript values. It uses the specified names in the R call as Javascript variable names. One can also specify qualifiers (‘public’, ‘protected’, ‘private’) and also types. These are optional, but useful, in ActionScript.

Usage

asJSVars(..., .vars = list(...), qualifier = character(), types = character())

Arguments

...

name = value pairs where the value is an R object that is converted to JSON format and name is the name of the corresponding Javascript variable.

.vars

this is an alternative to ... as a way to specify a collection of name = value pairs that is already in a list.

qualifier

a character vector (recycled as necessary) which is used as qualifiers for the individual ActionScript variables. The values should be public, protected or private.

types

either a logical value or a character vector (which is recycled if necessary). If this is TRUE, then we compute the Javascript type for each of the R objects (using the non-exported function jsType)

Value

A character vector of length 1 giving the variable declarations and initializations.

Author(s)

Duncan Temple Lang <duncan@wald.ucdavis.edu>

See Also

Examples

cat(asJSVars( a =  1:10, myMatrix = matrix(1:15, 3, 5)))
 cat(asJSVars( a =  1:10, myMatrix = matrix(1:15, 3, 5), types = TRUE))
 cat(asJSVars( a =  1:10, myMatrix = matrix(1:15, 3, 5),
        qualifier = "protected", types = TRUE))

RJSONIO

Serialize R Objects to JSON, JavaScript Object Notation

v1.3-1.4
BSD_3_clause + file LICENSE
Authors
CRAN Team [ctb, cre] (de facto maintainer since 2014), Duncan Temple Lang [aut] (<https://orcid.org/0000-0003-0159-1546>), Jonathan Wallace [aut] (aka ninja9578, author of included libjson sources)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.