.JavaArrayConstructor {Java}R Documentation

Create and access elements of Java arrays from R.

Description

These functions allow one to create multi-dimensional Java arrays via R commands using the .Java function. The get and set accessors work element-wise and not in the vector fashion common in R and S. One must create and initialize the Java virtual machine before calling any of these functions. See .JavaInit.

Usage

.JavaArrayConstructor(klass, ..., dim=length(list(...)), .name=NULL, .convert=F)
.JavaGetArrayElement(jobj,..., .name=NULL, .convert=T)
.JavaSetArrayElement(jobj, value, ...)
.JavaArrayLength(jobj)

Details

This uses the .Java to call methods in the Omegahat Evaluator which process the array request.

Value

.JavaArrayConstructor returns a reference to the newly create Java array object.
.JavaArrayLength returns a single integer giving the length of the top-level dimension of the array.
.JavaGetArrayElement returns the value of the specified element of the given array, converted to an R object as usual. Thus it may be a Java reference.
.JavaSetArrayElement returns NULL.

Author(s)

Duncan Temple Lang, John Chambers

References

http://www.javasoft.com, http://www.omegahat.org

See Also

.Java

Examples

 a <- .JavaArrayConstructor("String", dim=3)
 .JavaArrayLength(a)
 .JavaSetArrayElement(a, "First", 1)
 .JavaSetArrayElement(a, "Second", 2)
 .JavaSetArrayElement(a, "Third", 3)
 .JavaGetArrayElement(a, 2)