/**
   * returns a single Double result. Assumes that the R code uses the variable "results" for storing
   * the results of the process.
   *
   * @param template
   * @return
   */
  protected Double getSingleResult(String template) {
    code.clear();
    code.addRCode(template);

    String call = "results";

    caller.setRCode(code);
    caller.runAndReturnResultOnline(call);
    String[] res = caller.getParser().getAsStringArray(call);

    // the codestore is always updated at the end of the operation
    addToCodestore(code, call);

    return convertStringToNumber(res[0]);
  }
  protected void installPackageIfNotInstalled(String packageName) {
    code.clear();
    code.addRCode(
        "if(!('"
            + packageName
            + "' %in% installed.packages()[,\"Package\"])){install.packages('"
            + packageName
            + "')}");
    caller.setRCode(code);

    String call = "library('" + packageName + "')";

    caller.runAndReturnResultOnline("library('" + packageName + "')");
    // the codestore is always updated at the end of the operation
    addToCodestore(code, call);
  }