Package org.renjin.primitives.matrix

Examples of org.renjin.primitives.matrix.IntMatrixBuilder


  public SEXP buildFactorsMatrix() {
    if(terms.size() == 0) {
      return new IntArrayVector();
    } else {
      List<SEXP> variables = uniqueVariables();
      IntMatrixBuilder matrix = new IntMatrixBuilder(variables.size(), terms.size());
      matrix.setRowNames(Collections2.transform(variables, Functions.toStringFunction()));
      matrix.setColNames(buildTermLabels());
      for(int row = 0; row != variables.size(); ++row) {
        for(int col = 0; col != terms.size(); ++col) {
          if(terms.get(col).getExpressions().contains(
              variables.get(row))) {
            // TODO(alex): I don't know when this should be 1 or 2??
            matrix.set(row, col, 1);
          } else {
            matrix.set(row, col, 0);
          }
        }
      }
      return matrix.build();
    }
  }
View Full Code Here

TOP

Related Classes of org.renjin.primitives.matrix.IntMatrixBuilder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.