Package

org.ddahl

rscala

Permalink

package rscala

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 scala from the package rscala. It is through this instance R that callbacks to the original R interpreter are possible.

    In a Scala application, an instance of this class is created using its companion object. See below. The paths of the rscala's JARs (for all supported versions of Scala) are available from R using rscala::.rscalaJar(). To get just the JAR for Scala 2.12, for example, use rscala::.rscalaJar("2.12").

    val R = org.ddahl.rscala.RClient()
    
    val a = R.evalD0("rnorm(8)")
    val b = R.evalD1("rnorm(8)")
    val c = R.evalD2("matrix(rnorm(8),nrow=4)")
    
    R.set("ages", Array(4,2,7,9))
    R.ages = Array(4,2,7,9)
    println(R.getI1("ages").mkString("<",", ",">"))
    
    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. class REphemeralReference extends RReference

    Permalink

    A reference to an R object which is only guaranteed to be valid in the scope in which it was created.

  3. class RPersistentReference extends RReference

    Permalink

    A reference to an R object which persists beyond the scope in which it was created.

  4. sealed trait RReference extends AnyRef

    Permalink

    A reference to an R object.

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 scala 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 are available from R using rscala::.rscalaJar(). To get just the JAR for Scala 2.12, for example, use rscala::.rscalaJar("2.12").

    val R = org.ddahl.rscala.RClient()
  2. object REphemeralReference

    Permalink

    A reference to an R object which is only guaranteed to be valid in the scope in which it was created.

  3. object RPersistentReference

    Permalink

    A reference to an R object which persists beyond the scope in which it was created.

Ungrouped