^.rscalaBridge | R Documentation |
This operator is equivalent to *.rscalaBridge
, except the
return value is always an rscala reference. This operator also allows (a
small subset of) R code to be transcompiled to Scala code and produces an
rscala reference to an anonymous Scala function.
## S3 method for class 'rscalaBridge'
bridge ^ snippet
bridge |
A Scala bridge. |
snippet |
String providing a Scala code snippet. |
Returns an rscala reference.
*.rscalaBridge
, +.rscalaBridge
,
scala
s <- scala()
x <- s ^ 'new scala.util.Random()' # These two lines ...
x <- s $ .new_scala.util.Random() # ... are equivalent
s(rng=x) * 'rng.nextDouble()'
f <- s ^ function(x=scalaType('Double')) { pi - x }
f$apply(3.14)
s(n=10L, mapper=s ^ function(x=scalaType("Int")) { 2 * x }) * "Array.tabulate(n)(mapper)"
logStdNormalDensity <- s ^ function(x=scalaType("Double"), mean=0.0, sd=1.0) {
variance <- sd^2
-0.5*log(2*pi*variance) - 0.5/variance * (x-mean)^2
}
identical(logStdNormalDensity$apply(1.0), dnorm(1.0, log=TRUE))
close(s)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.