com.github.rcaller.rstuff.RCode Java Examples

The following examples show how to use com.github.rcaller.rstuff.RCode. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RSessionWrapper.java    From mzmine3 with GNU General Public License v2.0 5 votes vote down vote up
private void initNewRCaller() {

    this.rEngine = RCaller.create();
    RCode code = RCode.create();
    ((RCaller) this.rEngine).setRCode(code);

    this.wasRunAndReturned = false;
  }
 
Example #2
Source File: RSessionWrapper.java    From mzmine2 with GNU General Public License v2.0 5 votes vote down vote up
private void initNewRCaller() {

    this.rEngine = RCaller.create();
    RCode code = RCode.create();
    ((RCaller) this.rEngine).setRCode(code);

    this.wasRunAndReturned = false;
  }
 
Example #3
Source File: RCallerMean.java    From tutorials with MIT License 5 votes vote down vote up
/**
 * Invokes the customMean R function passing the given values as arguments.
 * 
 * @param values the input to the mean script
 * @return the result of the R script
 * @throws IOException        if any error occurs
 * @throws URISyntaxException if any error occurs
 */
public double mean(int[] values) throws IOException, URISyntaxException {
    String fileContent = RUtils.getMeanScriptContent();
    RCode code = RCode.create();
    code.addRCode(fileContent);
    code.addIntArray("input", values);
    code.addRCode("result <- customMean(input)");
    RCaller caller = RCaller.create(code, RCallerOptions.create());
    caller.runAndReturnResult("result");
    return caller.getParser()
        .getAsDoubleArray("result")[0];
}