当前位置: 首页>>代码示例>>Java>>正文


Java REXPMismatchException类代码示例

本文整理汇总了Java中org.rosuda.REngine.REXPMismatchException的典型用法代码示例。如果您正苦于以下问题:Java REXPMismatchException类的具体用法?Java REXPMismatchException怎么用?Java REXPMismatchException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


REXPMismatchException类属于org.rosuda.REngine包,在下文中一共展示了REXPMismatchException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: listCommands

import org.rosuda.REngine.REXPMismatchException; //导入依赖的package包/类
/**
 * @return available R commands
 */
public String[] listCommands() {
    silentlyEval(".keyWords <- function() {n <- length(search());result <- c();for (i in 1:n) {result <- c(result,ls(pos=i,all.names=TRUE))}; result}");
    REXP rexp = silentlyEval(".keyWords()");
    String as[] = null;
    try {
        if (rexp != null && (as = rexp.asStrings()) != null) {
            return as;
        } else {
            return null;
        }
    } catch (REXPMismatchException ex) {
        log(HEAD_ERROR + ex.getMessage() + "\n  listCommands()",
                Level.ERROR);
        return null;
    }
}
 
开发者ID:mzmine,项目名称:mzmine2,代码行数:20,代码来源:Rsession.java

示例2: asStringMatrix

import org.rosuda.REngine.REXPMismatchException; //导入依赖的package包/类
private String[][] asStringMatrix(final REXP rexp) throws REXPMismatchException {
    final String[] ct = rexp.asStrings();
    final REXP dim = rexp.getAttribute("dim");
    if (dim == null) {
        throw new REXPMismatchException(rexp, "matrix (dim attribute missing)");
    }
    final int[] ds = dim.asIntegers();
    if (ds.length != 2) {
        throw new REXPMismatchException(rexp, "matrix (wrong dimensionality)");
    }
    final int m = ds[0], n = ds[1];

    final String[][] r = new String[m][n];
    // R stores matrices as matrix(c(1,2,3,4),2,2) = col1:(1,2), col2:(3,4)
    // we need to copy everything, since we create 2d array from 1d array
    int k = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            r[j][i] = ct[k++];
        }
    }
    return r;
}
 
开发者ID:subes,项目名称:invesdwin-context-r,代码行数:24,代码来源:RserveScriptTaskResultsR.java

示例3: asIntegerMatrix

import org.rosuda.REngine.REXPMismatchException; //导入依赖的package包/类
private int[][] asIntegerMatrix(final REXP rexp) throws REXPMismatchException {
    final int[] ct = rexp.asIntegers();
    final REXP dim = rexp.getAttribute("dim");
    if (dim == null) {
        throw new REXPMismatchException(rexp, "matrix (dim attribute missing)");
    }
    final int[] ds = dim.asIntegers();
    if (ds.length != 2) {
        throw new REXPMismatchException(rexp, "matrix (wrong dimensionality)");
    }
    final int m = ds[0], n = ds[1];

    final int[][] r = new int[m][n];
    // R stores matrices as matrix(c(1,2,3,4),2,2) = col1:(1,2), col2:(3,4)
    // we need to copy everything, since we create 2d array from 1d array
    int k = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            r[j][i] = ct[k++];
        }
    }
    return r;
}
 
开发者ID:subes,项目名称:invesdwin-context-r,代码行数:24,代码来源:RserveScriptTaskResultsR.java

示例4: getBooleanVector

import org.rosuda.REngine.REXPMismatchException; //导入依赖的package包/类
@Override
public boolean[] getBooleanVector(final String variable) {
    try {
        final REXP rexp = engine.unwrap().eval(variable);
        if (allIsNa(rexp)) {
            return null;
        } else {
            final int[] ints = rexp.asIntegers();
            final boolean[] booleanVector = new boolean[ints.length];
            for (int i = 0; i < ints.length; i++) {
                booleanVector[i] = ints[i] > 0;
            }
            return booleanVector;
        }
    } catch (final REXPMismatchException e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:subes,项目名称:invesdwin-context-r,代码行数:19,代码来源:RserveScriptTaskResultsR.java

示例5: getBooleanMatrix

import org.rosuda.REngine.REXPMismatchException; //导入依赖的package包/类
@Override
public boolean[][] getBooleanMatrix(final String variable) {
    try {
        final REXP rexp = engine.unwrap().eval(variable);
        if (allIsNa(rexp)) {
            return null;
        } else {
            final double[][] matrix = rexp.asDoubleMatrix();
            final boolean[][] booleanMatrix = new boolean[matrix.length][];
            for (int i = 0; i < matrix.length; i++) {
                final double[] vector = matrix[i];
                final boolean[] booleanVector = new boolean[vector.length];
                for (int j = 0; j < vector.length; j++) {
                    booleanVector[j] = vector[j] > 0;
                }
                booleanMatrix[i] = booleanVector;
            }
            return booleanMatrix;
        }
    } catch (final REXPMismatchException e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:subes,项目名称:invesdwin-context-r,代码行数:24,代码来源:RserveScriptTaskResultsR.java

示例6: cat

import org.rosuda.REngine.REXPMismatchException; //导入依赖的package包/类
public static String cat(RList list) {
    try {
        StringBuffer sb = new StringBuffer("\t");
        double[][] data = new double[list.names.size()][];
        for (int i = 0; i < list.size(); i++) {
            String n = list.keyAt(i);
            sb.append(n + "\t");
            data[i] = list.at(n).asDoubles();
        }
        sb.append("\n");
        for (int i = 0; i < data[0].length; i++) {
            sb.append((i + 1) + "\t");
            for (int j = 0; j < data.length; j++) {
                sb.append(data[j][i] + "\t");
            }
            sb.append("\n");
        }
        return sb.toString();
    } catch (REXPMismatchException r) {
        return "(Not a numeric dataframe)\n"
                + new REXPList(list).toDebugString();
    }
}
 
开发者ID:mzmine,项目名称:mzmine2,代码行数:24,代码来源:Rsession.java

示例7: isPackageLoaded

import org.rosuda.REngine.REXPMismatchException; //导入依赖的package包/类
/**
 * Check for package loaded in R environment.
 * 
 * @param pack
 *            R package name
 * @return package loading status
 */
public boolean isPackageLoaded(String pack) {
    silentlyVoidEval(loadedpacks + "<-.packages()", false);
    boolean isloaded = false;
    try {
        REXP i = silentlyEval("is.element(set=" + loadedpacks + ",el='"
                + pack + "')");
        if (i != null) {
            isloaded = i.asInteger() == 1;
        }
    } catch (REXPMismatchException ex) {
        log(HEAD_ERROR + ex.getMessage()
                + "\n  isPackageLoaded(String pack=" + pack + ")",
                Level.ERROR);
    }
    if (isloaded) {
        log(_PACKAGE_ + pack + " is loaded.", Level.INFO);
    } else {
        log(_PACKAGE_ + pack + " is not loaded.", Level.INFO);
    }

    // silentlyEval("rm(" + loadedpacks + ")");
    return isloaded;
}
 
开发者ID:mzmine,项目名称:mzmine2,代码行数:31,代码来源:Rsession.java

示例8: typeOf

import org.rosuda.REngine.REXPMismatchException; //导入依赖的package包/类
/**
 * 
 * @param robject
 *            R object name
 * @return R type of object
 */
public String typeOf(String robject) {
    if (robject == null) {
        return "NULL";
    }
    for (String t : types) {
        REXP is = silentlyEval("is." + t + "(" + robject + ")");
        try {
            if (is != null && is.asInteger() == 1) {
                return t;
            }
        } catch (REXPMismatchException ex) {
            log(HEAD_ERROR + "[typeOf] " + robject + " type unknown.",
                    Level.ERROR);
            return null;
        }
    }
    return "unknown";
}
 
开发者ID:mzmine,项目名称:mzmine2,代码行数:25,代码来源:Rsession.java

示例9: set

import org.rosuda.REngine.REXPMismatchException; //导入依赖的package包/类
/**
 * Set R list in R env.
 * 
 * @param varname
 *            R list name
 * @param data
 *            numeric data in list
 * @param names
 *            names of columns
 */
public boolean set(String varname, double[][] data, String... names) {
    RList list = buildRList(data, names);
    log(HEAD_SET + varname + " <- " + toString(list), Level.INFO);
    try {
        synchronized (connection) {
            connection.assign(varname, REXP.createDataFrame(list));
        }
    } catch (REXPMismatchException re) {
        log(HEAD_ERROR + " RList " + list.toString()
                + " not convertible as dataframe.", Level.ERROR);
        return false;
    } catch (RserveException ex) {
        log(HEAD_EXCEPTION + ex.getMessage() + "\n  set(String varname="
                + varname + ",double[][] data, String... names)",
                Level.ERROR);
        return false;
    }
    return true;
}
 
开发者ID:mzmine,项目名称:mzmine2,代码行数:30,代码来源:Rsession.java

示例10: asString

import org.rosuda.REngine.REXPMismatchException; //导入依赖的package包/类
/**
 * Get R command text output
 * 
 * @param command
 *            R command returning text
 * @return String
 */
public String asString(String command) {
    try {
        String s = silentlyEval(
                "paste(capture.output(print(" + command
                        + ")),collapse='\\n')").asString();
        return s;
    } catch (REXPMismatchException ex) {
        return ex.getMessage();
    }
    /*
     * String[] lines = null; try { lines = silentlyEval("capture.output( "
     * + command + ")").asStrings(); } catch (REXPMismatchException e) {
     * return e.getMessage(); } if (lines == null) { return ""; }
     * StringBuffer sb = new StringBuffer(); for (String l : lines) {
     * sb.append(l); sb.append("\n"); } return sb.toString();
     */
}
 
开发者ID:mzmine,项目名称:mzmine2,代码行数:25,代码来源:Rsession.java

示例11: removeFile

import org.rosuda.REngine.REXPMismatchException; //导入依赖的package包/类
/**
 * Remove a file on the RServer.
 * @param filename File to remove
 */
public void removeFile(final String filename) throws REngineException {

  // Test if the file exists
  final RConnection c = getRConnection();

  try {

    REXP exists = c.eval("file.exists(\"" + filename + "\")");
    if (exists.asInteger() == 1) {
      c.voidEval("file.remove(\"" + filename + "\")");
    }

  } catch (RserveException | REXPMismatchException e) {
    throw new REngineException(c, "RServe exception: " + e);
  }
}
 
开发者ID:GenomicParisCentre,项目名称:eoulsan,代码行数:21,代码来源:RSConnection.java

示例12: getOutputFiles

import org.rosuda.REngine.REXPMismatchException; //导入依赖的package包/类
@Override
public void getOutputFiles() throws IOException {

  checkConnection();

  try {

    // Get all the filenames
    final List<String> filenames = this.rConnection.listFiles();

    for (String filename : filenames) {

      // Retrieve the file
      this.rConnection.getFile(filename,
          new File(getOutputDirectory(), filename));

      // Delete the file
      removeFile(filename);
    }

  } catch (REngineException | REXPMismatchException e) {
    throw new IOException(e);
  }
}
 
开发者ID:GenomicParisCentre,项目名称:eoulsan,代码行数:25,代码来源:RserveRExecutor.java

示例13: CellHTS2

import org.rosuda.REngine.REXPMismatchException; //导入依赖的package包/类
public CellHTS2(ScreenResult screenResult, 
                String title,
                String reportsPath,
                String saveRObjectsPath) throws RserveException, REngineException,
REXPMismatchException {
  this.screenResult = screenResult;
  this.rConnection = new RConnection();
  this.arrayDimensions = calculateArrayDimensions(screenResult);
  this.title = title;
  this.reportsPath = reportsPath;
  if (!StringUtils.isEmpty(saveRObjectsPath)) {
    this.saveRObjectsPath = saveRObjectsPath;
    File file = new File(saveRObjectsPath);
    if (file.exists()) {
      this.saveRObjects = true;
    }
    else {
      log.error(saveRObjectsPath +
        "does not exist (cellHTS2.saveRObjects.directory system property); R objects will not be saved");
    }
  }
}
 
开发者ID:hmsiccbl,项目名称:screensaver,代码行数:23,代码来源:CellHTS2.java

示例14: getConfigureDbResultSlog

import org.rosuda.REngine.REXPMismatchException; //导入依赖的package包/类
public String[][] getConfigureDbResultSlog() throws RserveException, REngineException, REXPMismatchException {
  
  // Example screenlog: data.frame(Plate=c(1),Well=c("A02"),Sample=c(1),Flag=c("NA"),Channel=c(1),stringsAsFactors=FALSE)
  
  RserveExtensions rserveExtensions = new RserveExtensions();
  REXP rexpPlate = rserveExtensions.tryEval(rConnection, "screenLog <- [email protected]; resultContent <- screenLog$Plate");
  REXP rexpWell = rserveExtensions.tryEval(rConnection, "resultContent <- screenLog$Well");
  REXP rexpSample = rserveExtensions.tryEval(rConnection, "resultContent <- screenLog$Sample");    //Sample = Replicate
  REXP rexpFlag = rserveExtensions.tryEval(rConnection, "resultContent <- screenLog$Flag");
  REXP rexpChannel = rserveExtensions.tryEval(rConnection,"resultContent <- screenLog$Channel");
  
  String [][] result =null;
  if (!rexpPlate.isNull()) {
    // all have the same length
    result = new String[5][rexpPlate.asStrings().length];
    result[0] = rexpPlate.asStrings();
    result[1] = rexpWell.asStrings();
    result[2] = rexpSample.asStrings();
    result[3] = rexpFlag.asStrings();
    result[4] = rexpChannel.asStrings();
 
  }

  return result;
}
 
开发者ID:hmsiccbl,项目名称:screensaver,代码行数:26,代码来源:CellHTS2.java

示例15: convertOutputRserve

import org.rosuda.REngine.REXPMismatchException; //导入依赖的package包/类
public double[][][] convertOutputRserve (REXP output)  throws REXPMismatchException{
  int[] dim = output.dim();

  double[][][] result = new double[dim[0]][dim[1]][dim[2]];
  
  int h = -1;

  for (int k = 0; k < dim[2]; k++) {
    for (int j = 0; j < dim[1]; j++) {
        for (int i = 0; i < dim[0]; i++) {
          h++;
          result[i][j][k] = output.asDoubles()[h];
      }          
    }        
  }
  return result;
}
 
开发者ID:hmsiccbl,项目名称:screensaver,代码行数:18,代码来源:CellHTS2.java


注:本文中的org.rosuda.REngine.REXPMismatchException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。