Description Usage Arguments Details Value See Also Examples
The function convertToJava
converts R objects to generic Java objects for use with the rJava package. This function simplifies and extends data exchange for rJava. The function convertToJava
is the inverse of convertToR
.
1 2 3 4 5 6 7 8 | convertToJava(
value,
length.one.vector.as.array = FALSE,
scalars.as.objects = FALSE,
array.order = "row-major",
data.frame.row.major = TRUE,
coerce.factors = TRUE
)
|
value |
An R vector, matrix, n-dimensional array, table, factor, data frame, list, or environment. Nested lists are supported. Supported data types: numeric, integer, character, logical, and raw. |
length.one.vector.as.array |
A logical vector of length one. See R Vectors of Length One in the vignette. |
scalars.as.objects |
A logical vector of length one. See R Vectors of Length One in the vignette. |
array.order |
A character vector of length one specifying the order when copying R n-dimensional arrays to Java. Valid values are |
data.frame.row.major |
A logical vector of length one. When |
coerce.factors |
A logical vector of length one. When |
The convertToJava
function is used to create objects that can be used as method parameters in the rJava package. R vectors, matrices, n-dimensional arrays, tables, factors, data frames, environments, lists, named lists, and nested lists are supported as well as data types numeric, integer, logical, character and raw.
The vignette contains all documentation for convertToJava
and its inverse function convertToR
. Note that these functions are not always perfect inverses of each other. See Conversion Issues for more information.
A Java object reference or an R vector. See the vignette for details.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | library("jdx")
# Convert matrix using column-major ordering
m <- matrix(1:4, 2, 2)
o = convertToJava(m, array.order = "column-major")
getJavaClassName(o)
identical(m, convertToR(o, array.order = "column-major"))
# Convert 4-dimensional array using row-major ordering
dimensions <- c(3, 2, 2, 2)
a = array(1:prod(dimensions), dimensions)
o = convertToJava(a, array.order = "row-major")
getJavaClassName(o)
identical(a, convertToR(o, array.order = "row-major"))
# Convert data frame
identical(iris, convertToR(convertToJava(iris)))
# Demonstrate exact double precision
identical(pi, convertToR(convertToJava(pi, scalars.as.objects = TRUE)))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.