public Object asNativeJavaObject() throws REXPMismatchException { // since REXPGenericVector does the hard work, we just cheat and use it in turn REXPGenericVector v = new REXPGenericVector(payload); return v.asNativeJavaObject(); }
cont = (xt==XT_VECTOR_EXP)? new REXPExpressionVector(l, getAttr()): new REXPGenericVector(l, getAttr()); } else cont = (xt==XT_VECTOR_EXP)? new REXPExpressionVector(new RList(v), getAttr()): new REXPGenericVector(new RList(v), getAttr()); return o;
public String toString() { return super.toString()+(asList().isNamed()?"named":""); }
cont = (xt==XT_VECTOR_EXP)? new REXPExpressionVector(l, getAttr()): new REXPGenericVector(l, getAttr()); } else cont = (xt==XT_VECTOR_EXP)? new REXPExpressionVector(new RList(v), getAttr()): new REXPGenericVector(new RList(v), getAttr()); return o;
public String toString() { return super.toString()+(asList().isNamed()?"named":""); }
public Object asNativeJavaObject() throws REXPMismatchException { // since REXPGenericVector does the hard work, we just cheat and use it in turn REXPGenericVector v = new REXPGenericVector(payload); return v.asNativeJavaObject(); }
/** creates a data frame object from a list object using integer row names * @param l a (named) list of vectors ({@link REXPVector} subclasses), each element corresponds to a column and all elements must have the same length * @return a data frame object * @throws REXPMismatchException if the list is empty or any of the elements is not a vector */ public static REXP createDataFrame(RList l) throws REXPMismatchException { if (l == null || l.size() < 1) throw new REXPMismatchException(new REXPList(l), "data frame (must have dim>0)"); if (!(l.at(0) instanceof REXPVector)) throw new REXPMismatchException(new REXPList(l), "data frame (contents must be vectors)"); REXPVector fe = (REXPVector) l.at(0); return new REXPGenericVector(l, new REXPList( new RList( new REXP[] { new REXPString("data.frame"), new REXPString(l.keys()), new REXPInteger(new int[] { REXPInteger.NA, -fe.length() }) }, new String[] { "class", "names", "row.names" }))); }
/** creates a data frame object from a list object using integer row names * @param l a (named) list of vectors ({@link REXPVector} subclasses), each element corresponds to a column and all elements must have the same length * @return a data frame object * @throws REXPMismatchException if the list is empty or any of the elements is not a vector */ public static REXP createDataFrame(RList l) throws REXPMismatchException { if (l==null || l.size()<1) throw new REXPMismatchException(new REXPList(l), "data frame (must have dim>0)"); if (!(l.at(0) instanceof REXPVector)) throw new REXPMismatchException(new REXPList(l), "data frame (contents must be vectors)"); REXPVector fe = (REXPVector) l.at(0); return new REXPGenericVector(l, new REXPList( new RList( new REXP[] { new REXPString("data.frame"), new REXPString(l.keys()), new REXPInteger(new int[] { REXPInteger.NA, -fe.length() }) }, new String[] { "class", "names", "row.names" }))); }