Package org.renjin.sexp

Examples of org.renjin.sexp.SEXP


    }
    this.numRows = Models.nrows(frame.getElementAsSEXP(0));
   
    variables = Lists.newArrayList();
    for(int i=0; i!=frame.length(); ++i) {
      SEXP vector = frame.getElementAsSEXP(i);
      if(Models.nrows(vector) != numRows) {
        throw new EvalException("variable lengths differ");
      }
      variables.add(createVariable(frame.getName(i), vector));
    }
View Full Code Here


    return (Vector)frame.getAttribute(Symbols.ROW_NAMES);
  }
 
  public static int ncols(SEXP s)
  {
      SEXP t;
      if (s instanceof Vector) {
        Vector dim = (Vector) s.getAttribute(Symbols.DIM);
        if(dim.length() >= 2) {
          return dim.getElementAsInt(1);
        } else {
View Full Code Here

   * @throws IOException
   */
  private void processRDataFile(File dataFile) throws IOException {
    Closer closer = Closer.create();
    InputStream in = closer.register(DatasetsBuilder.decompress(dataFile));
    SEXP exp;
    try {
      RDataReader reader = new RDataReader(in);
      exp = reader.readFile();
    } catch(Throwable e) {
      throw closer.rethrow(e);
    } finally {
      in.close();
    }
   
    if(!(exp instanceof PairList)) {
      throw new UnsupportedOperationException("Expected to find a pairlist in " + dataFile + ", found a " + exp.getTypeName());
    }
   
    String logicalDatasetName = stripExtension(dataFile.getName());
    Session session = new SessionBuilder().withoutBasePackage().build();
    writePairList(logicalDatasetName, session, (PairList)exp);
View Full Code Here

  public FqPackageName getFullyQualifiedName() {
    return pkg.getName();
  }

  public SEXP getEntry(Symbol entry) {
    SEXP value = namespaceEnvironment.getVariable(entry);
    if(value == Symbol.UNBOUND_VALUE) {
      throw new EvalException("Namespace " + pkg.getName() + " has no symbol named '" + entry + "'");
    }
    return value;
  }
View Full Code Here

    FunctionCall readTable = FunctionCall.newCall(Symbol.get("::"), Symbol.get("utils"), Symbol.get("read.table"));
    FunctionCall call = new FunctionCall(readTable, args.build());

    Session session = new SessionBuilder().build();
    SEXP dataFrame = session.getTopLevelContext().evaluate(call);

    PairList.Builder pairList = new PairList.Builder();
    pairList.add(logicalDatasetName, dataFrame);

    writePairList(logicalDatasetName, session, pairList.build());
View Full Code Here

  @Override
  public Object interpret(Context context, Object[] temp) {
    Symbol target = ((EnvironmentVariable) getLHS()).getName();
    SEXP rhs = (SEXP) getRHS().retrieveValue(context, temp);
    Environment rho = context.getEnvironment();

    for(Environment env : context.getEnvironment().parents()) {
      if(env.hasVariable(target))  {
        env.setVariable(target, rhs);
View Full Code Here

  @Test
  public void licenseTest() throws IOException {
  
   
    SEXP conn = openResourceAsConn("/org/renjin/share/licenses/license.db");
    topLevelContext.getEnvironment().setVariable("x",
        DebianControlFiles.readDCF(topLevelContext, conn, Null.INSTANCE, true));
   
    assertThat(eval("dim(x)"), equalTo(c_i(29,7)));
    assertThat(eval("dimnames(x)[[1]]"), equalTo(NULL));
View Full Code Here

  @Test
  public void continuationTest() throws IOException {
  
   
    SEXP conn = openResourceAsConn("continuation.dcf");
    SEXP db = DebianControlFiles.readDCF(topLevelContext, conn, Null.INSTANCE, true);
      
    topLevelContext.getEnvironment().setVariable("x",
        db);

   
View Full Code Here

  @Override
  public Expression translateToExpression(IRBodyBuilder builder,
      TranslationContext context, FunctionCall call) {
  
    PairList formals = EvalException.checkedCast(call.getArgument(0));
    SEXP body = call.getArgument(1);
    SEXP source = call.getArgument(2);

    return new MakeClosure(builder.newFunction(formals, body));
  }
View Full Code Here

  @Test
  public void multipleReads() throws IOException {

    FileObject file = VFS.getManager().resolveFile(getClass().getResource("test2.txt").getFile());
    SEXP conn = topLevelContext.getSession().getConnectionTable().newConnection(new GzFileConnection(file));

    assertThat( Connections.readChar(topLevelContext, conn, 9, false), equalTo("The quick"));
    assertThat( Connections.readChar(topLevelContext, conn, 6, false), equalTo(" brown"));

  }
View Full Code Here

TOP

Related Classes of org.renjin.sexp.SEXP

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.