Package org.rosuda.JRI

Examples of org.rosuda.JRI.RList


        for (Enumeration e = v.getNames().elements() ; e.hasMoreElements() ;) {
          System.out.println(e.nextElement());
        }
      }
      // for compatibility with Rserve we allow casting of vectors to lists
      RList vl = x.asList();
      String[] k = vl.keys();
      if (k!=null) {
        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++; }
          System.out.println("");
      }
     
      // 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:
      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:");
        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


        for (Enumeration e = v.getNames().elements() ; e.hasMoreElements() ;) {
          System.out.println(e.nextElement());
        }
      }
      // for compatibility with Rserve we allow casting of vectors to lists
      RList vl = x.asList();
      String[] k = vl.keys();
      if (k!=null) {
        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++; }
          System.out.println("");
      }
     
      // 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:
      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:");
        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

        }
        predictedValues.put(name, vectorSubResult);
        break;
       
      case REXP.XT_LIST:
        RList rList = rResult.asList();
        Map<String, Object> listSubResult = new HashMap<String, Object>();
        for(String lName : rList.keys()) {
          processRResult(rList.at(lName), listSubResult, lName);
        }
        predictedValues.put(name, listSubResult);
        break;
      default:
        log.log(Level.WARNING, "Unsopported R expression/result type " + rResult.getType() + ". Will not add it to predicted values");
View Full Code Here

        for (Enumeration e = v.getNames().elements() ; e.hasMoreElements() ;) {
          System.out.println(e.nextElement());
        }
      }
      // for compatibility with Rserve we allow casting of vectors to lists
      RList vl = x.asList();
      String[] k = vl.keys();
      if (k!=null) {
        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++; }
          System.out.println("");
      }
     
      // 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:
      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:");
        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

TOP

Related Classes of org.rosuda.JRI.RList

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.