Package

org.ddahl

rscala

Permalink

package rscala

Visibility
  1. Public
  2. All

Type Members

  1. class RClient extends AnyRef

    Permalink

    A bridge to R.

    A bridge to R.

    In a Scala application, an instance of this class is created using its companion object as shown below.

    In an R script, the object R is an instance of this class available in an rscala bridge created by calling the function scala from the package rscala. It is through this instance that callbacks to the original R interpreter are possible.

    All of the evaluation methods of this class have the same signature. The first argument is a template for an R expression, where %- is a placeholder for items that are provided as variable arguments. The result type is indicated by the suffix of the method name. See examples below.

    This class is threadsafe.

    val R = org.ddahl.rscala.RClient()
    
    val a = R.evalD0("sd(rnorm(1000, mean=%-, sd=%-))", 1.0, 2.0)
    
    R.eval("primes <- %-", Array(2, 3, 5, 7, 11, 13, 17, 19, 23))
    val rFunction = R.evalObject("function(x) x*primes")
    val primesTimesTwo = R.evalI1("%-(2)", rFunction)
    
    val m = R.evalI2("matrix(rbinom(%-, size=10, prob=0.5), nrow=2)", 8)
    
    R.quit()
  2. final class RObject extends AnyRef

    Permalink

Value Members

  1. object RClient

    Permalink

    The companion object to the RClient class used to create an instance in a Scala application.

    The companion object to the RClient class used to create an instance in a Scala application.

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

Ungrouped