Learn R Programming

rscala (version 3.1.0)

scalaPackage: Embed a Scala Bridge in a Package

Description

This function should be called in the .onLoad function of a depending package.

Usage

scalaPackage(packages = character(), assign.callback = function(s) { },
  assign.name = "s", JARs = character(), mode = "", ...)

Arguments

packages

Character vector of package names whose embedded JAR files are to be added to the classpath.

assign.callback

A function taking a Scala bridge as its only argument. This function is called immediately after the bridge is connected, which does not happen until the bridge is actually used and may be long after this function finishes. This is where setup code goes, like global imports, objects, classes, methods, etc. For example, it might equal function(s) { s + 'import scala.util.Random' }. Note the use of the execution operator + instead of the evaluation operator *.

assign.name

The name of the (promise of the) bridge to be assigned in the environment given by the assign.env argument.

JARs

Character vector whose elements are individual JAR files to be added to the runtime classpath.

mode

A string. If the package is to have its own bridge, this should be "". If the package is to use the bridge of another package (e.g., package "foo"), then this should be the fully qualified variable of that package (e.g., "foo:::s").

...

When using mode="", other arguments passed to the function scala.

Value

Returns NULL, invisibly.

Details

The function makes an rscala bridge available to the functions of the package. Package developers should call this function in the package's .onLoad function. The scalaPackageUnload function should be called in the package's .onUnload function.

See Also

scalaPackageUnload, scala

Examples

Run this code
# NOT RUN {
.onLoad <- function(libname, pkgname) {
  scalaPackage(c(pkgname, "commonsMath"), function(s) s + "
    import org.apache.commons.math3._
  ")
}
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab