Giter Site home page Giter Site logo

bedatadriven / renjin Goto Github PK

View Code? Open in Web Editor NEW
507.0 37.0 82.0 42.48 MB

JVM-based interpreter for the R language for the statistical analysis.

Home Page: https://www.renjin.org

License: GNU General Public License v2.0

Java 19.65% Fortran 9.89% R 58.15% Shell 0.01% Makefile 0.01% HTML 0.03% Assembly 0.01% C 11.63% Yacc 0.15% Lex 0.08% Groovy 0.02% C++ 0.27% Roff 0.07% FreeMarker 0.01% NASL 0.03%
r renjin interpreter language java compiler statistics

renjin's Introduction

renjin

Build Status

Renjin is a JVM-based interpreter for the The R Project for Statistical Computing.

The primary goals of the project are to provide a modern interpreter that serves as a drop-in replacement for GNU R, but is easier to integrate with other systems, offers better performance, and is more extensible.

For more information, please visit http://www.renjin.org.

Installation

Standalone distributions of Renjin are available for ad-hoc analysis. Downloads are available at renjin.org.

Artifacts from the latest successful build are available from the build server here.

Debian (and Ubuntu)

You can add our APT repository and get regular updates automatically:

# 1. Add the Renjin repository signing keys to be able to verify downloaded packages
sudo apt-key adv --keyserver hkp://packages.renjin.org:80 --recv-keys EB2514FC345926E9

# 2. Add the Renjin repository
echo deb http://packages.renjin.org/repo/apt stable main | sudo tee /etc/apt/sources.list.d/renjin.list

# 3. Update list of available packages
sudo apt-get update

# 4. Install Renjin
sudo apt-get install renjin

Please see our Downloads page.

Adding to a Maven Project

Using a a modern build tool such a Maven is definitely recommended, particularly if you're planning on including R packages which often have several levels of transitive dependencies.

You can add Renjin to your Maven project by adding the following to your pom.xml file:

<dependencies>
  <dependency>
    <groupId>org.renjin</groupId>
    <artifactId>renjin-script-engine</artifactId>
    <version>RELEASE</version>
  </dependency>
</dependencies>
<repositories>
  <repository>
    <id>bedatadriven</id>
    <name>bedatadriven public repo</name>
    <url>https://nexus.bedatadriven.com/content/groups/public/</url>
  </repository>
</repositories>

Compiling from Source

At this time, building Renjin completely is only supported on Ubuntu 16.04. The resulting Java builds are fully platform-independent.

See BUILDING for more information.

License

Renjin is available under the GPLv2 (or higher) license, see LICENSE for the full text of the license. Renjin also includes code from R which is redistributed here. R uses many different licenses so check the file sources to see which license applies.

renjin's People

Contributors

akbertram avatar alain-bearez avatar billy1380 avatar const-ae avatar cwlaird3 avatar hannes avatar hlin09 avatar hwvenancio avatar jarrodmoldrich avatar jukiewiczm avatar kurthornik avatar lrbrinks92 avatar mjkallen avatar mmaechler avatar pernyfelt avatar peter-gergely-horvath avatar psolaimani avatar rssh avatar sebkur avatar strboul avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

renjin's Issues

str() fails on a list

In 0.7.0-RC7 I get the following error:

> str(list(name="Jane",age=23))
List of 2
 $ name:ERROR: Unmatched positional arguments
  at match.call()
  at match()
  at %w/o%()
  at strSub()
  at str.default()
  at str()

Migrate to latest version of Guava Library

Exception in thread "main" java.lang.NoSuchMethodError: com.google.common.io.Closeables.closeQuietly(Ljava/io/Closeable;)V
at org.renjin.primitives.packaging.ClasspathPackage.resourceExists(ClasspathPackage.java:62)
at org.renjin.primitives.packaging.ClasspathPackage.exists(ClasspathPackage.java:28)
at org.renjin.primitives.packaging.ClasspathPackageLoader.load(ClasspathPackageLoader.java:33)
at org.renjin.primitives.packaging.ClasspathPackageLoader.load(ClasspathPackageLoader.java:12)
at org.renjin.primitives.packaging.NamespaceRegistry.load(NamespaceRegistry.java:81)
at org.renjin.primitives.packaging.NamespaceRegistry.getNamespace(NamespaceRegistry.java:63)
at org.renjin.primitives.packaging.NamespaceRegistry.getNamespace(NamespaceRegistry.java:76)
at org.renjin.primitives.packaging.Packages.library(Packages.java:30)
at org.renjin.primitives.R$primitive$library.doApply(R$primitive$library.java from WrapperSource:70)
at org.renjin.primitives.R$primitive$library.apply(R$primitive$library.java from WrapperSource:31)
at org.renjin.eval.Context.evaluateCall(Context.java:261)
at org.renjin.eval.Context.evaluate(Context.java:193)
at org.renjin.eval.Context.evaluate(Context.java:161)
at org.renjin.eval.SessionBuilder.build(SessionBuilder.java:72)
at org.renjin.script.RenjinScriptEngineFactory.getScriptEngine(RenjinScriptEngineFactory.java:94)
at org.renjin.script.RenjinScriptEngineFactory.getScriptEngine(RenjinScriptEngineFactory.java:14)
at javax.script.ScriptEngineManager.getEngineByName(ScriptEngineManager.java:235)
at com.clearcapital.re.service.RulesEngineService.initialize(RulesEngineService.java:31)
at io.dropwizard.Application.run(Application.java:70)
at com.clearcapital.re.service.RulesEngineService.main(RulesEngineService.java:24)

Should this dependency have been loaded by Renjin?

warning() gives an error

The following is tested in 0.7.0-RC7 (Jenkins build 1489):

> x<-1
> warning("x is ",x)
ERROR: not that many frames on the stack
  at warning()
> 

System.procTime triggers Error in AppEngine environment

java.lang.NoClassDefFoundError: java.lang.management.ManagementFactory is a restricted class. Please see the Google App Engine developer's guide for more details.
at com.google.appengine.tools.development.agent.runtime.Runtime.reject(Runtime.java:51)
at org.renjin.primitives.System.procTime(System.java:331)
at org.renjin.primitives.R$primitive$proc$time.doApply(R$primitive$proc$time.java from WrapperSource:65)
at org.renjin.primitives.R$primitive$proc$time.apply(R$primitive$proc$time.java from WrapperSource:27)
at org.renjin.eval.Context.evaluateCall(Context.java:261)
at org.renjin.eval.Context.evaluate(Context.java:193)
at org.renjin.primitives.special.AssignLeftFunction.assignLeft(AssignLeftFunction.java:60)
at org.renjin.primitives.special.AssignLeftFunction.apply(AssignLeftFunction.java:44)
at org.renjin.eval.Context.evaluateCall(Context.java:261)
at org.renjin.eval.Context.evaluate(Context.java:193)
at org.renjin.primitives.special.BeginFunction.apply(BeginFunction.java:46)
at org.renjin.eval.Context.evaluateCall(Context.java:261)
at org.renjin.eval.Context.evaluate(Context.java:193)
at org.renjin.eval.Context.evaluate(Context.java:161)
at org.renjin.sexp.Closure.doApply(Closure.java:108)
at org.renjin.eval.ClosureDispatcher.apply(ClosureDispatcher.java:80)
at org.renjin.eval.ClosureDispatcher.applyClosure(ClosureDispatcher.java:65)
at org.renjin.sexp.Closure.apply(Closure.java:82)
at org.renjin.eval.Context.evaluateCall(Context.java:261)
at org.renjin.eval.Context.evaluate(Context.java:193)
at org.renjin.primitives.special.AssignLeftFunction.assignLeft(AssignLeftFunction.java:60)
at org.renjin.primitives.special.AssignLeftFunction.apply(AssignLeftFunction.java:44)
at org.renjin.eval.Context.evaluateCall(Context.java:261)
at org.renjin.eval.Context.evaluate(Context.java:193)
at org.renjin.primitives.special.BeginFunction.apply(BeginFunction.java:46)
at org.renjin.eval.Context.evaluateCall(Context.java:261)
at org.renjin.eval.Context.evaluate(Context.java:193)
at org.renjin.eval.Context.evaluate(Context.java:161)
at org.renjin.sexp.Closure.doApply(Closure.java:108)
at org.renjin.eval.ClosureDispatcher.apply(ClosureDispatcher.java:80)
at org.renjin.eval.ClosureDispatcher.applyClosure(ClosureDispatcher.java:65)
at org.renjin.sexp.Closure.apply(Closure.java:82)

Implement ComplexVector.newCopyBuilder()

ERROR: implement mejava.lang.UnsupportedOperationException: implement me
at org.renjin.sexp.ComplexVector.newCopyBuilder(ComplexVector.java:195)
at org.renjin.sexp.ComplexVector.newCopyBuilder(ComplexVector.java:33)
at org.renjin.primitives.subset.SubscriptOperation.createReplacementBuilder(SubscriptOperation.java:306)
at org.renjin.primitives.subset.SubscriptOperation.replace(SubscriptOperation.java:238)
at org.renjin.primitives.subset.Subsetting.setSubset(Subsetting.java:237)

is.finite() should gracefully deal with any atomic vector

Currently, is.finite() in Renjin throws an error if no double is passed:

> is.finite("Inf")
ERROR: Invalid argument:
    is.finite(character)
    Expected:
    is.finite(double)

whereas in GNU R is.finite() will return FALSE for character vectors. The same holds for is.infinite()

Missing logger

Upon startup, Renjin shows the following message which indicates that a logger is missing:

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.

missing header in CLI and incorrect header in Studio

The CLI currently does not output a header like GNU R does and the header in de Studio (i.e. GUI) is not showing the correct version number.

TODO: create a uniform header in the CLI, Studio GUI and the Appengine demo which includes the correct version number.

Merge, a rather core R function, is not properly implemented

It looks like the R-language merge function calls what was in GNU R an "internal" function written in C.

This internal function needs to be ported to Java or to R.

WARNING: Failure: org.renjin.eval.EvalException: Sorry! merge not yet implemented!

I see code here:

https://code.google.com/p/renjin/source/browse/core/src/main/R/base/merge.R?spec=svn749380717d8168f447dea4d3ca1d06d3603fdaab&r=749380717d8168f447dea4d3ca1d06d3603fdaab

WARNING: Failure: org.renjin.eval.EvalException: Sorry! merge not yet implemented!
org.renjin.primitives.Primitives$1.apply(Primitives.java:115)
org.renjin.primitives.special.InternalFunction.apply(InternalFunction.java:55)
org.renjin.eval.Context.evaluateCall(Context.java:261)
org.renjin.eval.Context.evaluate(Context.java:193)
org.renjin.primitives.special.AssignLeftFunction.assignLeft(AssignLeftFunction.java:60)
org.renjin.primitives.special.AssignLeftFunction.apply(AssignLeftFunction.java:44)
org.renjin.eval.Context.evaluateCall(Context.java:261)
org.renjin.eval.Context.evaluate(Context.java:193)
org.renjin.primitives.special.IfFunction.apply(IfFunction.java:46)
org.renjin.eval.Context.evaluateCall(Context.java:261)
org.renjin.eval.Context.evaluate(Context.java:193)
org.renjin.primitives.special.BeginFunction.apply(BeginFunction.java:46)
org.renjin.eval.Context.evaluateCall(Context.java:261)
org.renjin.eval.Context.evaluate(Context.java:193)
org.renjin.primitives.special.IfFunction.apply(IfFunction.java:50)
org.renjin.eval.Context.evaluateCall(Context.java:261)
org.renjin.eval.Context.evaluate(Context.java:193)
org.renjin.primitives.special.BeginFunction.apply(BeginFunction.java:46)
org.renjin.eval.Context.evaluateCall(Context.java:261)
org.renjin.eval.Context.evaluate(Context.java:193)
org.renjin.eval.Calls.applyClosure(Calls.java:71)
org.renjin.primitives.S3$GenericMethod.doApply(S3.java:585)
org.renjin.primitives.S3$GenericMethod.apply(S3.java:572)
org.renjin.primitives.S3.UseMethod(S3.java:43)
org.renjin.primitives.S3.UseMethod(S3.java:35)
org.renjin.primitives.R$primitive$UseMethod.doApply(R$primitive$UseMethod.java from WrapperSource:77)
org.renjin.primitives.R$primitive$UseMethod.apply(R$primitive$UseMethod.java from WrapperSource:31)
org.renjin.eval.Context.evaluateCall(Context.java:261)
org.renjin.eval.Context.evaluate(Context.java:193)
org.renjin.eval.Context.evaluate(Context.java:161)
org.renjin.sexp.Closure.doApply(Closure.java:108)
org.renjin.eval.ClosureDispatcher.apply(ClosureDispatcher.java:80)
org.renjin.eval.ClosureDispatcher.applyClosure(ClosureDispatcher.java:65)
org.renjin.sexp.Closure.apply(Closure.java:82)
org.renjin.eval.Context.evaluateCall(Context.java:261)
org.renjin.eval.Context.evaluate(Context.java:193)
org.renjin.primitives.special.AssignLeftFunction.assignLeft(AssignLeftFunction.java:60)
org.renjin.primitives.special.AssignLeftFunction.apply(AssignLeftFunction.java:44)
org.renjin.eval.Context.evaluateCall(Context.java:261)
org.renjin.eval.Context.evaluate(Context.java:193)
org.renjin.primitives.special.BeginFunction.apply(BeginFunction.java:46)
org.renjin.eval.Context.evaluateCall(Context.java:261)
org.renjin.eval.Context.evaluate(Context.java:193)
org.renjin.eval.Context.evaluate(Context.java:161)
org.renjin.sexp.Closure.doApply(Closure.java:108)
org.renjin.eval.ClosureDispatcher.apply(ClosureDispatcher.java:80)
org.renjin.eval.ClosureDispatcher.applyClosure(ClosureDispatcher.java:65)
org.renjin.sexp.Closure.apply(Closure.java:82)
org.renjin.eval.Context.evaluateCall(Context.java:261)
org.renjin.eval.Context.evaluate(Context.java:193)
org.renjin.primitives.special.AssignLeftFunction.assignLeft(AssignLeftFunction.java:60)
org.renjin.primitives.special.AssignLeftFunction.apply(AssignLeftFunction.java:44)
org.renjin.eval.Context.evaluateCall(Context.java:261)
org.renjin.eval.Context.evaluate(Context.java:193)
org.renjin.primitives.special.BeginFunction.apply(BeginFunction.java:46)
org.renjin.eval.Context.evaluateCall(Context.java:261)
org.renjin.eval.Context.evaluate(Context.java:193)
org.renjin.eval.Context.evaluate(Context.java:161)
org.renjin.sexp.Closure.doApply(Closure.java:108)
org.renjin.eval.ClosureDispatcher.apply(ClosureDispatcher.java:80)
org.renjin.eval.ClosureDispatcher.applyClosure(ClosureDispatcher.java:65)
org.renjin.sexp.Closure.apply(Closure.java:82)
org.renjin.eval.Context.evaluateCall(Context.java:261)
org.renjin.eval.Context.evaluate(Context.java:193)
org.renjin.eval.Context.evaluate(Context.java:161)
org.renjin.script.RenjinScriptEngine.invoke(RenjinScriptEngine.java:232)
org.renjin.script.RenjinScriptEngine.invokeFunction(RenjinScriptEngine.java:201)
org.renjin.script.RenjinScriptEngine.invokeFunction(RenjinScriptEngine.java:19)
...

IllegalArgumentException when a string includes a "!"

Using the 0.7.0-RC6 Debian package:

See the example below. Same happens with cat("hello!") and with paste("hello", "!").

> print("hello")
[1] "hello"
> print("hello!")

java.lang.IllegalArgumentException: !"): event not found
    at jline.console.ConsoleReader.expandEvents(ConsoleReader.java:702)
    at jline.console.ConsoleReader.finishBuffer(ConsoleReader.java:577)
    at jline.console.ConsoleReader.accept(ConsoleReader.java:1883)
    at jline.console.ConsoleReader.readLine(ConsoleReader.java:2455)
    at jline.console.ConsoleReader.readLine(ConsoleReader.java:2126)
    at jline.console.ConsoleReader.readLine(ConsoleReader.java:2114)
    at org.renjin.repl.JlineReader.read(JlineReader.java:39)
    at java.io.Reader.read(Reader.java:121)
    at java.io.FilterReader.read(FilterReader.java:65)
    at java.io.PushbackReader.read(PushbackReader.java:90)
    at org.renjin.parser.RLexerReader.read(RLexerReader.java:38)
    at org.renjin.parser.RLexer.xxgetc(RLexer.java:683)
    at org.renjin.parser.RLexer.isEof(RLexer.java:1230)
    at org.renjin.repl.JlineRepl.readExpression(JlineRepl.java:111)
    at org.renjin.repl.JlineRepl.run(JlineRepl.java:92)
    at org.renjin.cli.Main.main(Main.java:60)

patched netlib does not use vecLib on Mac OS X

In order to use the current netlib java release 1.1.1 (and vecLib on Mac OS X), I had to modify a few files in renjin and rebuild. The changes are as follows:

modify

./core/pom.xml 
./appl/pom.xml 

and replace the netlib dependency with:

<dependency>
    <groupId>com.github.fommil.netlib</groupId>
    <artifactId>all</artifactId>
    <version>1.1.1</version>
    <type>pom</type>
 </dependency>

Then I had to fix the package imports on the following Java source files:

core/src/main/java/org/renjin/primitives/matrix/MatrixProduct.java
core/src/main/java/org/renjin/base/Lapack.java
appl/src/main/java/org/renjin/appl/ExternalRoutines.java

The new imports are (instead of org.netlib.blas.BLAS):

import com.github.fommil.netlib.BLAS
import com.github.fommil.netlib.LAPACK

Implement subst for fixed regular expressions

java.lang.UnsupportedOperationException: subst not yet implemented for fixed RE
at org.renjin.primitives.text.regex.FixedRE.subst(FixedRE.java:53)
at org.renjin.primitives.text.Text.sub(Text.java:292)
at org.renjin.primitives.R$primitive$sub.doApply(R$primitive$sub.java from WrapperSource:147)
at org.renjin.primitives.R$primitive$sub.apply(R$primitive$sub.java from WrapperSource:39)
at org.renjin.primitives.special.InternalFunction.apply(InternalFunction.java:55)
at org.renjin.eval.Context.evaluateCall(Context.java:251)
at org.renjin.eval.Context.evaluate(Context.java:183)
at org.renjin.primitives.special.BeginFunction.apply(BeginFunction.java:46)
at org.renjin.eval.Context.evaluateCall(Context.java:251)
at org.renjin.eval.Context.evaluate(Context.java:183)
at org.renjin.eval.Context.evaluate(Context.java:160)
at org.renjin.sexp.Closure.doApply(Closure.java:108)

Settings file for interactive mode

Read settings for interactive mode from settings files that include at the very least:

  • Additional remote repositories
  • Default GroupId for artifact resolution

Load R packages

I'm running through some issues trying to include R packages. The error is :shared object 'plyr.dll' not found.

I hope you could help me.

Thank you

runif(n) doesn't check for the length of n

If length(n) > 1 in runif(n), it should return a vector of the same length as n. Right now, Renjin returns a vector of length 1:

> runif(seq(3))
[1] 0.68255795428875

which, using GNU R, should return something like

> runif(seq(3))
[1] 0.24899961 0.08148573 0.56745381

The same holds for the other random number generators, i.e. rnorm(), rweibull(), etc.

model.frame fails with error 'number of variables != number of variable names'

xvals = c(-1.9137300, -0.9354530, 0.6309640, 0.3108570, 0.0431084)
yvals = c(-0.799904, -0.493735, -0.653075, -0.018258, 1.253210)
rvals = c(2.040010, 0.959304, 0.728477, 0.301885, 1.190120)

sample = data.frame(x=xvals, y=yvals, radius=rvals)
errors <- 1/sample$radius^2

print(sample)

fit <- nls(radius ~ sqrt(abs((x-x0))^2+abs((y-y0))^2), data = sample,
start=list(x0=sample[1,]$x, y0=sample[1,]$y), weights = errors)

solution <- summary(fit)$coefficients[,1]
print(solution)
print(summary(fit))

Implement detach()

Attempting to detach a loaded package namespace will display the message

ERROR: Sorry! detach not yet implemented!

and spit out a Java stack trace.

Can't find/use an external library

Hi, i can't use the library "arules" because Renjin keep giving me this error. How can i use it? I don't know how to set the "classpath" of the package (and where should i do it?)... Thanks

Exception in thread "main" org.renjin.eval.EvalException: arules could not be found
at org.renjin.primitives.packaging.NamespaceRegistry.load(NamespaceRegistry.java:83)
at org.renjin.primitives.packaging.NamespaceRegistry.getNamespace(NamespaceRegistry.java:63)
at org.renjin.primitives.packaging.NamespaceRegistry.getNamespace(NamespaceRegistry.java:76)
at org.renjin.primitives.packaging.Packages.library(Packages.java:30)
at org.renjin.primitives.R$primitive$library.doApply(R$primitive$library.java from WrapperSource:70)
at org.renjin.primitives.R$primitive$library.apply(R$primitive$library.java from WrapperSource:31)
at org.renjin.eval.Context.evaluateCall(Context.java:261)
at org.renjin.eval.Context.evaluate(Context.java:193)
at org.renjin.eval.Context.evaluateExpressionVector(Context.java:252)
at org.renjin.eval.Context.evaluate(Context.java:191)
at org.renjin.script.RenjinScriptEngine.eval(RenjinScriptEngine.java:131)
at org.renjin.script.RenjinScriptEngine.eval(RenjinScriptEngine.java:95)
at agents.RTest.main(RTest.java:14)

write.csv(..) is not implemented.

write.csv(..) and capture.output(.) , is not implemented. I believe this is a very important feature of R..could this be implemented ASAP. or provide some alternatives?

Wrong extension returned

Hi, there seems to be an error in the value returned by the getExtensions() method of the ScriptEngineFactory when using Renjin.
When doing:

for (ScriptEngineFactory factory : new ScriptEngineManager().getEngineFactories()) {
            try {
                System.out.printf("%s (%s) - engine: %s (%s)", factory.getLanguageName(), factory.getLanguageVersion(), factory.getEngineName(), factory.getEngineVersion());
                for (String name : factory.getNames()) {
                    System.out.printf("\t\"%s\"", name);
                }
                System.out.print(" - ");
                for (String type : factory.getMimeTypes()) {
                    System.out.printf("\t\"%s\"", type);
                }
                System.out.print(" - ");
                for (String extension : factory.getExtensions()) {
                    System.out.printf("\t\"%s\"", extension);
                }
                System.out.println();
            } catch (Exception ex) {
                final String message = String.format("Error loading factory %s", factory);
                Logger.getLogger(AlInFXML.class.getName()).log(Level.SEVERE, message, ex);
            }
        }

The Renjin script engine factory returns a single file extension that has the value of ".R".
Other scripting languages that you can use in the JVM all return a value without the . (dot) character as follows:

jruby                                    "rb"
jython                                  "py"
JavaScript/Rhin                   "js"

This causes an issue when, in JavaFX, we want to use a FXML which has some R code stored in an external script:

<?xml version="1.0" encoding="UTF-8"?>

<?import java.lang.*?>
<?import java.util.*?>
<?import javafx.scene.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<?language Renjin?>

<AnchorPane id="AnchorPane" prefHeight="400.0" prefWidth="600.0" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/2.2">
  <fx:script source="script.R"/>
  <children>
    <Button layoutX="14.0" layoutY="14.0" mnemonicParsing="false" text="Button" onAction="sayHello(event);" />
  </children>
</AnchorPane>

In this FXML the code for the sayHello funtion is stored in the file script.R. We tell the FXML that is code is using Renjin using the entity.

With a Script.R file that contains:

sayHello <- function(event) {
    print("Hello World!")
}

and some Java code to load the content similar to:

import java.io.IOException;
import java.net.URL;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.scene.layout.AnchorPane;
import javafx.stage.Stage;
import javax.script.ScriptException;

/**
 *
 * @author fabriceb
 */
public class SimpleRTest extends Application {

    @Override
    public void start(final Stage primaryStage) throws IOException, ScriptException {
        final String fxmlFilename = "ROuterInFXML.fxml";
        final URL fxmlURL = getClass().getResource(fxmlFilename);
        final FXMLLoader fxmlLoader = new FXMLLoader(fxmlURL);
        final Node control = (Node) fxmlLoader.load();
        AnchorPane.setTopAnchor(control, 0d);
        AnchorPane.setLeftAnchor(control, 0d);
        AnchorPane.setBottomAnchor(control, 0d);
        AnchorPane.setRightAnchor(control, 0d);
        final AnchorPane root = new AnchorPane();
        root.getChildren().add(control);
        final Scene scene = new Scene(root, 500, 500);
        final String title = "R Outer";
        primaryStage.setTitle(title);
        primaryStage.setScene(scene);
        primaryStage.show();

    }

    /**
     * The main() method is ignored in correctly deployed JavaFX 
     * application. main() serves only as fallback in case the 
     * application can not be launched through deployment artifacts,
     * e.g., in IDEs with limited FX support. NetBeans ignores main().
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        launch(args);
    }
}

At runtime, this code generates the following error:

javafx.fxml.LoadException: Unable to locate scripting engine for extension R.
    at javafx.fxml.FXMLLoader$ScriptElement.processStartElement(FXMLLoader.java:1318)
    at javafx.fxml.FXMLLoader.processStartElement(FXMLLoader.java:2356)
    at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2172)
    at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2069)
    at alinfxml.SimpleRTest.start(SimpleRTest.java:29)
    at com.sun.javafx.application.LauncherImpl$5.run(LauncherImpl.java:319)
    at com.sun.javafx.application.PlatformImpl$5.run(PlatformImpl.java:219)
    at com.sun.javafx.application.PlatformImpl$4$1.run(PlatformImpl.java:182)
    at com.sun.javafx.application.PlatformImpl$4$1.run(PlatformImpl.java:179)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.javafx.application.PlatformImpl$4.run(PlatformImpl.java:179)
    at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:76)
    at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    at com.sun.glass.ui.win.WinApplication.access$100(WinApplication.java:17)
    at com.sun.glass.ui.win.WinApplication$3$1.run(WinApplication.java:67)

When using other script engines such as Jython, Jruby or Rhino no such error occur :

For Rhino:

<?language javascript?>

<AnchorPane id="AnchorPane" prefHeight="400.0" prefWidth="600.0" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/2.2">
  <fx:script source="script.js"/>

For JRuby:

<?language jruby?>

<AnchorPane id="AnchorPane" prefHeight="400.0" prefWidth="600.0" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/2.2">
  <fx:script source="script.rb"/>

For Jython:

<?language python?>

<AnchorPane id="AnchorPane" prefHeight="400.0" prefWidth="600.0" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/2.2">
  <fx:script source="script.py"/>

So I believe that the getExtensions() method of the ScriptEngineFactory when using Renjin should returnd "R" not ".R"

Easy installation method for MS Windows users

Renjin currently does not have an easy installation method for MS Windows users. Possible solutions: DOS batch file based on the (Linux) shell script in the bin folder, Java Web Start, (fat) JAR, etc.

What is the license of this project?

I have looked at README, the root project folder, and one source file, and could not find a license. Under what terms am I formally allowed to use this project? (If none is provided, default copyright laws apply, which are too restrictive to count as open source.)

enc2xxx should be stubbed out

ScriptEngineManager factory = new ScriptEngineManager();
ScriptEngine engine = factory.getEngineByName("Renjin");
engine.eval("adist('abc', 'abd')");

This leads to the exception:
Exception in thread "main" org.renjin.eval.EvalException: could not find function 'enc2utf8'

Inconsistent behavior of Vectorize

I was testing the live demo and found a problem with Vectorize. In some cases it worked as expected, in others nothing was returned by the Vectorized function.

For example, this worked:

Vectorize(function(x)sum(x))(c(1,2,3))

but this did not:

Vectorize(function(y)sum(y))(c(1,2,3))

-klausbh

tilde expansion does not work

Doing something like setwd("~/Documents") gives an error. setwd("home/joe/Documents") works as it should.

Using 0.7.0-RC7-SNAPSHOT, build #1487

predict method applied to simple linear model causes "Error: invalid attribute 'response'" in Renjin Studio.

To reproduce:

ONE)
Setup data file.
In your OS shell (assuming you run *nix, cygwin):

cat > /tmp/data
sqFt,bathrooms,priceInThousands
1200,1,750
1250,2,900
2000,2.5,1500

TWO)
Launch Studio

THREE)
Type the following in Studio window>>

values <- read.csv("/tmp/data")
newModel.lm = lm(priceInThousands ~ sqFt + bathrooms, data=values)
newdata = data.frame(sqFt=1700, bathrooms=2)
predict(newModel.lm , newdata)

FOUR)

Observe error:

Error: invalid attribute 'response'

model.frame() does not support multivate response variables

i copied the orcutt script into my R script, but it is failing at:

java.lang.UnsupportedOperationException
at org.renjin.stats.internals.models.NumericVariable.getModelMatrixColumns(NumericVariable.java:37)
at org.renjin.stats.internals.models.TermsObject$Term.getModelMatrixColumns(TermsObject.java:131)
at org.renjin.stats.internals.models.ModelMatrixBuilder.build(ModelMatrixBuilder.java:38)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.