Learn R Programming

rscala (version 2.5.3)

scalaConvert: Convert an R object to a Scala reference.

Description

These functions convert R objects to Scala references and vice versa. The function scalaConvert supports copyable types whereas scalaConvert.data.frame supports data frames. These functions provide prototypes for others to write their own conversions for other types. Factors in data frames are converted to strings when converting to Scala.

Usage

scalaConvert(x, interpreter = findScalaInstance())

scalaConvert.data.frame(x, interpreter = findScalaInstance())

Arguments

x

An R object to convert to a Scala reference.

interpreter

An instance of a Scala interpreter.

Examples

Run this code
# NOT RUN {
scala(serialize.output=TRUE)

identical(pi, scalaConvert(scalaConvert(pi)))

identical(mtcars, scalaConvert.data.frame(scalaConvert.data.frame(mtcars)))

dfInScala <- scalaConvert.data.frame(ToothGrowth)
dfInScala$keys()
dfInScala$apply("supp")$"_2"()
dfInScala$apply("supp")$"_1"()
# }

Run the code above in your browser using DataLab