Package org.rosuda.JRI

Examples of org.rosuda.JRI.Rengine.eval()


    /* High-level API - do not use RNI methods unless there is no other way
      to accomplish what you want */
    try {
      REXP x;
      re.eval("data(iris)",false);
      System.out.println(x=re.eval("iris"));
      // generic vectors are RVector to accomodate names
      RVector v = x.asVector();
      if (v.getNames()!=null) {
        System.out.println("has names:");
View Full Code Here


    /* High-level API - do not use RNI methods unless there is no other way
      to accomplish what you want */
    try {
      REXP x;
      re.eval("data(iris)",false);
      System.out.println(x=re.eval("iris"));
      // generic vectors are RVector to accomodate names
      RVector v = x.asVector();
      if (v.getNames()!=null) {
        System.out.println("has names:");
        for (Enumeration e = v.getNames().elements() ; e.hasMoreElements() ;) {
View Full Code Here

        System.out.println("and once again from the list:");
        int i=0; while (i<k.length) System.out.println(k[i++]);
      }     

      // get boolean array
      System.out.println(x=re.eval("iris[[1]]>mean(iris[[1]])"));
      // R knows about TRUE/FALSE/NA, so we cannot use boolean[] this way
      // instead, we use int[] which is more convenient (and what R uses internally anyway)
      int[] bi = x.asIntArray();
      {
          int i = 0; while (i<bi.length) { System.out.print(bi[i]==0?"F ":(bi[i]==1?"T ":"NA ")); i++; }
View Full Code Here

      }
     
      // push a boolean array
      boolean by[] = { true, false, false };
      re.assign("bool", by);
      System.out.println(x=re.eval("bool"));
      // asBool returns the first element of the array as RBool
      // (mostly useful for boolean arrays of the length 1). is should return true
      System.out.println("isTRUE? "+x.asBool().isTRUE());

      // now for a real dotted-pair list:
View Full Code Here

      // asBool returns the first element of the array as RBool
      // (mostly useful for boolean arrays of the length 1). is should return true
      System.out.println("isTRUE? "+x.asBool().isTRUE());

      // now for a real dotted-pair list:
      System.out.println(x=re.eval("pairlist(a=1,b='foo',c=1:5)"));
      RList l = x.asList();
      if (l!=null) {
        int i=0;
        String [] a = l.keys();
        System.out.println("Keys:");
View Full Code Here

        while (i<a.length) System.out.println(a[i++]);
        System.out.println("Contents:");
        i=0;
        while (i<a.length) System.out.println(l.at(i++));
      }
      System.out.println(re.eval("sqrt(36)"));
    } catch (Exception e) {
      System.out.println("EX:"+e);
      e.printStackTrace();
    }
   
View Full Code Here

                System.out.println("");
            }
            System.out.println("");
        }
        {
            REXP x=re.eval("1:10");
            System.out.println("REXP result = "+x);
            int d[]=x.asIntArray();
            if (d!=null) {
                int i=0; while (i<d.length) { System.out.print(((i==0)?"":", ")+d[i]); i++; }
                System.out.println("");
View Full Code Here

    /* High-level API - do not use RNI methods unless there is no other way
      to accomplish what you want */
    try {
      REXP x;
      re.eval("library(statnet)");
      re.eval("data(\"faux.magnolia.high\")", false);
      re.eval("fmh <- faux.magnolia.high", false);
      re.eval("plot(fmh,displayisolates = FALSE, vertex.col = \"Grade\", vertex.cex = 0.7)");
     
      re.eval("data(iris)",false);
View Full Code Here

                int i=0; while (i<d.length) { System.out.print(((i==0)?"":", ")+d[i]); i++; }
                System.out.println("");
            }
        }

        re.eval("print(1:10/3)");
       
  if (true) {
      // so far we used R as a computational slave without REPL
      // now we start the loop, so the user can use the console
      System.out.println("Now the console is yours ... have fun");
View Full Code Here

    /* High-level API - do not use RNI methods unless there is no other way
      to accomplish what you want */
    try {
      REXP x;
      re.eval("library(statnet)");
      re.eval("data(\"faux.magnolia.high\")", false);
      re.eval("fmh <- faux.magnolia.high", false);
      re.eval("plot(fmh,displayisolates = FALSE, vertex.col = \"Grade\", vertex.cex = 0.7)");
     
      re.eval("data(iris)",false);
      System.out.println(x=re.eval("iris"));
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.