jarray {rJava}R Documentation

Creates a Java array from a vector

Description

.jarray takes a vector (or a list of Java references) as its argument, creates a Java array containing the elements of the vector (or list) and returns a reference to such newly created array.

Usage

.jarray(x)

Arguments

x vector or a list of Java references

Details

The input can be either a vector of some sort (such as numeric, integer, logical, ...) or a list of Java references. The contents is pushed to the Java side and a corresponding array is created. The type of the array depends on the input vector type. For example numeric vector creates double[] array, integer vector creates int[] array, character vector String[] array and so on. If x is a list, it must contain Java references only (or NULLs which will be treaded as NULL references).

The result is a reference to the newly created array.

The inverse function which fetches the elements of an array reference is .jevalArray.

Value

Returns a Java object reference (jobjRef) of a null object having the specified object class.

Examples

## Not run: 
a <- .jarray(1:10)
a
.jevalArray(a)
b <- .jarray(c("hello","world"))
b
c <- .jarray(list(a,b))
c
## End(Not run)

[Package rJava version 0.3-6 Index]