Description Usage Arguments Details Value See Also Examples
The function convertToR
converts the Java objects referenced by rJava objects to R objects. The function convertToR
is the inverse of convertToJava
.
1 2 3 4 5 | convertToR(
value,
strings.as.factors = NULL,
array.order = "row-major"
)
|
value |
An rJava object reference. |
strings.as.factors |
A logical vector of length one specifying whether string vectors are automatically converted to factors when Java objects are converted to R data frames. This parameter is discussed in the vignette under Java Maps. |
array.order |
A character vector of length one specifying the order used to copy Java n-dimensional arrays to R. Valid values are |
The convertToR
function is not thread-safe. Do not simultaneously call convertToR
from different threads in the same process. A thread-safe alternative is presented in the R documentation for convertToRlowLevel
.
The vignette contains all documentation for convertToR
and its inverse function convertToJava
. Note that these functions are not always perfect inverses of each other. See Conversion Issues for more information.
An R object. See the vignette for details.
convertToJava
, getJavaClassName
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.