Learn R Programming

rscala (version 3.2.6)

scala: Instantiate a Scala Bridge

Description

This function creates an instance of an rscala bridge. Details on this function (and the rscala package as a whole) are provided in the package vignette and the associated paper in the Journal of Statistical Software. See the reference below.

Usage

scala(JARs = character(), serialize.output = .Platform$OS.type ==
  "windows", stdout = TRUE, stderr = TRUE, port = 0L,
  heap.maximum = NULL, debug = FALSE)

Arguments

JARs

Character vector whose elements are some combination of individual JAR files or package names which contain embedded JARs. These JAR files are added to the runtime classpath.

serialize.output

Logical indicating whether Scala output should be serialized back to R. This is slower and probably only needed on Windows.

stdout

Whether "standard output" results that are not serialized should be sent. TRUE or "" sends output to the R console (although that may not work on Windows). FALSE or NULL discards the output. Otherwise, this is the name of the file that receives the output.

stderr

Same as stdout, except influences the "standard error".

port

If 0, two random ports are selected. Otherwise, port and port+1 are used to the TCP/IP connections.

heap.maximum

String giving Scala's heap maximum, e.g., "8G" or "512M". The value here supersedes that from scalaMemory. Without this being set in either scala or scalaMemory, the heap maximum will be 90% of the available RAM.

debug

(Developer use only.) Logical indicating whether debugging should be enabled.

Value

Returns an rscala bridge.

Details

Multiple interpreters can be created and each runs independently with its own memory space. Each interpreter can use multiple threads/cores, but the bridge between R and Scala is itself not thread-safe, so multiple R threads/cores should not simultaneously access the same bridge.

Terminate the bridge using close.rscalaBridge.

References

David B. Dahl (2018). <U+201C>Integration of R and Scala Using rscala.<U+201D> Journal of Statistical Software, in editing. https://www.jstatsoft.org

See Also

close.rscalaBridge, scalaMemory scalaPushRegister, scalaPullRegister

Examples

Run this code
# NOT RUN {
s <- scala()
rng <- s $ .new_scala.util.Random()
rng $ alphanumeric() $ take(15L) $ mkString(',')
s * '2+3'
h <- s(x=2, y=3) ^ 'x+y'
h $ toString()
s(mean=h, sd=2, r=rng) * 'mean + sd * r.nextGaussian()'
close(s)
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab