String[] names = payload.keys(); if (names.length == n) { HashMap map = new HashMap();
String[] names = payload.keys(); if (names.length == n) { HashMap map = new HashMap();
/** creates a new generic vector from a list. If the list is named, the <code>"names"</code> attribute is created automatically from it. * @param list list to create the vector from */ public REXPGenericVector(RList list) { super(); payload=(list==null)?new RList():list; // automatically generate 'names' attribute if (payload.isNamed()) attr = new REXPList( new RList(new REXP[] { new REXPString(payload.keys()) }, new String[] { "names" })); }
/** creates a new generic vector from a list. If the list is named, the <code>"names"</code> attribute is created automatically from it. * @param list list to create the vector from */ public REXPGenericVector(RList list) { super(); payload=(list==null)?new RList():list; // automatically generate 'names' attribute if (payload.isNamed()) attr = new REXPList( new RList(new REXP[] { new REXPString(payload.keys()) }, new String[] { "names" })); }
RList resultList = results.asList(); assert (resultList.keys().length == outputPorts.size()); for (OutputPort outputPort : outputPorts) { String portName = outputPort.getName();
/** 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" }))); }