Package

org.ddahl.rscala

callback

Permalink

package callback

Visibility
  1. Public
  2. All

Type Members

  1. class RClient extends Dynamic

    Permalink

    An interface to an R interpreter.

    An interface to an R interpreter.

    An object R is the instance of this class available in a Scala interpreter created by calling the function scalaInterpreter from the package rscala. It is through this instance R that callbacks to the original R interpreter are possible.

    In a JVM-based application, an instance of this class is created using its companion object. See below. The paths of the rscala's JARs, for both Scala 2.10 and 2.11, are available from R using rscala::rscalaJar(). To get just the JAR for Scala 2.11, for example, use rscala::rscalaJar("2.11").

    val R = org.ddahl.rscala.callback.RClient()
    
    val a = R.evalD0("rnorm(8)")
    val b = R.evalD1("rnorm(8)")
    val c = R.evalD2("matrix(rnorm(8),nrow=4)")
    
    R eval """
      v <- rbinom(8,size=10,prob=0.4)
      m <- matrix(v,nrow=4)
    """
    val v1 = R.get("v")
    val v2 = R.get("v")._1.asInstanceOf[Array[Int]]   // This works, but is not very convenient
    val v3 = R.v._1.asInstanceOf[Array[Int]]          // Slightly better
    val v4 = R.getI0("v")   // Get the first element of R's "v" as a Int
    val v5 = R.getI1("v")   // Get R's "v" as an Array[Int]
    val v6 = R.getI2("m")   // Get R's "m" as an Array[Array[Int]]
  2. case class RObject(name: String) extends Product with Serializable

    Permalink

    A class used to wrap an arbitrary R object.

    A class used to wrap an arbitrary R object.

    val R = org.ddahl.rscala.callback.RClient()
    R.a = Array(1,2,3,4,5)
    val ref = R.evalR("as.list(a)")
    R.evalD0(s"sum(unlist(${ref}))")

Value Members

  1. object RClient

    Permalink

    The companion object to the RClient class used to create an instance of the RClient class in a JVM-based application.

    The companion object to the RClient class used to create an instance of the RClient class in a JVM-based application.

    An object R is an RClient instance available in a Scala interpreter created by calling the function scalaInterpreter from the package rscala. It is through this instance R that callbacks to the original R interpreter are possible.

    The paths of the rscala's JARs, for both Scala 2.10 and 2.11, are available from R using rscala::rscalaJar(). To get just the JAR for Scala 2.11, for example, use rscala::rscalaJar("2.11").

    val R = org.ddahl.rscala.callback.RClient()

Ungrouped