scalaPull | R Documentation |
The push function serializes an R object to Scala and the push function does
the opposite. A couple of built push and pull methods are provided, namely
"generic"
and "list"
. The "generic"
method serializes an
arbitrary R object to an instance of RObject
in Scala. Since the
RObject
merely contains an array of bytes, the RObject
is
really only useful as storage for later unserialization. The "generic"
method has an optional as.is
argument which is either TRUE
to
cause the list to serialized as a single object or FALSE
to cause each
element of the list to the serialized individually. More methods may be added
using the functions scalaPushRegister
and
scalaPullRegister
.
scalaPull(reference, method, ...)
scalaPush(x, method = "generic", bridge = scalaFindBridge(), ...)
reference |
An rscala reference. |
method |
A string giving the specific 'push' or 'pull' method to use. |
... |
Other arguments passed to specialized push and pull functions. |
x |
An R object. |
bridge |
A Scala bridge. |
scalaPushRegister
, scalaPullRegister
s <- scala()
s(rn=scalaPush(rnorm),n=5) * 'R.evalD1("%-(%-)",rn,n)'
mtcarsRef <- scalaPush(mtcars, "list")
mtcarsRef$names()
mtcarsRef$mpg()
mtcars2 <- scalaPull(mtcarsRef, "list")
identical(mtcars, mtcars2)
# Oops, the variable names are bad...
tryCatch(ref <- scalaPush(iris, "list"), error=function(e) e)
# ... so let's clean up the variable names.
irisCleaned <- iris
names(irisCleaned) <- gsub("\\W","_",names(iris))
irisCleaned$Species <- as.character(iris$Species)
ref2 <- scalaPush(irisCleaned, "list")
scalaType(ref2)
ref2$Sepal_Length()
irisCleaned2 <- scalaPull(ref2,"list")
identical(irisCleaned, irisCleaned2)
close(s)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.